-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget.sh
More file actions
44 lines (36 loc) · 1.16 KB
/
Copy pathget.sh
File metadata and controls
44 lines (36 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
set -euo pipefail
# Support CLI args or fallback to environment variables
SPRINT_NAME="${1:-${SPRINT_NAME:-}}"
PROJECT_ID="${2:-${PROJECT_ID:-}}"
# Ensure both are set
: "${SPRINT_NAME:?Must provide SPRINT_NAME as argument or environment variable}"
: "${PROJECT_ID:?Must provide PROJECT_ID as argument or environment variable}"
echo "Using sprint: $SPRINT_NAME"
echo "Using project ID: $PROJECT_ID"
# cleanup .tmp directory
if [ -d .tmp ]; then
echo "Cleaning up old .tmp directory..."
rm -rf .tmp
fi
mkdir -p .tmp
echo "Fetch all items (unfiltered)..."
gh project item-list "$PROJECT_ID" --owner fleetdm --limit 1000 --format json > .tmp/items.json
echo "Fetch comments for filtered issues..."
jq --arg sprint "$SPRINT_NAME" '
.items
| map(select(
.content != null
and .content.type == "Issue"
and (
(.status != "Done")
or (.sprint == null)
or (.sprint != null and .sprint.title == $sprint)
)
))
| .[].content.number
' .tmp/items.json |
while read -r issue; do
echo "Fetching comments for issue #$issue"
gh issue view "$issue" --repo fleetdm/fleet --json comments > ".tmp/comments-${issue}.json"
done