Skip to content

Commit be50803

Browse files
authored
ci: add reusable workflow to move Linear tickets to Deployed (#21)
1 parent aaf9259 commit be50803

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Move Linear tickets to Deployed
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
release_body:
7+
required: true
8+
type: string
9+
team_key:
10+
required: false
11+
type: string
12+
default: 'SDK'
13+
secrets:
14+
LINEAR_GITHUB_API_KEY:
15+
required: true
16+
17+
jobs:
18+
update-linear:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Update Linear tickets to Deployed
22+
env:
23+
LINEAR_GITHUB_API_KEY: ${{ secrets.LINEAR_GITHUB_API_KEY }}
24+
TEAM_KEY: ${{ inputs.team_key }}
25+
run: |
26+
RELEASE_BODY=$(cat <<'EOF'
27+
${{ inputs.release_body }}
28+
EOF
29+
)
30+
31+
TICKETS=$(echo "$RELEASE_BODY" | grep -oE 'SDK-[0-9]+' | sort -u)
32+
33+
if [ -z "$TICKETS" ]; then
34+
echo "No SDK tickets found in release notes"
35+
exit 0
36+
fi
37+
38+
STATE_ID=$(curl -s -X POST https://api.linear.app/graphql \
39+
-H "Authorization: $LINEAR_GITHUB_API_KEY" \
40+
-H "Content-Type: application/json" \
41+
-d "{\"query\": \"{ workflowStates(filter: { name: { eq: \\\"Deployed\\\" }, team: { key: { eq: \\\"$TEAM_KEY\\\" } } }) { nodes { id } } }\"}" \
42+
| jq -r '.data.workflowStates.nodes[0].id')
43+
44+
echo "Deployed state ID: $STATE_ID"
45+
46+
for TICKET in $TICKETS; do
47+
NUM=$(echo "$TICKET" | grep -oE '[0-9]+')
48+
echo "Processing $TICKET..."
49+
50+
ISSUE_ID=$(curl -s -X POST https://api.linear.app/graphql \
51+
-H "Authorization: $LINEAR_GITHUB_API_KEY" \
52+
-H "Content-Type: application/json" \
53+
-d "{\"query\": \"{ issueSearch(filter: { number: { eq: $NUM }, team: { key: { eq: \\\"$TEAM_KEY\\\" } } }) { nodes { id title } } }\"}" \
54+
| jq -r '.data.issueSearch.nodes[0].id // empty')
55+
56+
if [ -z "$ISSUE_ID" ]; then
57+
echo " ⚠️ $TICKET not found in Linear"
58+
continue
59+
fi
60+
61+
RESULT=$(curl -s -X POST https://api.linear.app/graphql \
62+
-H "Authorization: $LINEAR_GITHUB_API_KEY" \
63+
-H "Content-Type: application/json" \
64+
-d "{\"query\": \"mutation { issueUpdate(id: \\\"$ISSUE_ID\\\", input: { stateId: \\\"$STATE_ID\\\" }) { success issue { identifier title } } }\"}")
65+
66+
echo " ✅ $TICKET → Deployed"
67+
done

0 commit comments

Comments
 (0)