forked from stripe/link-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathissue-triggered-create-jira.yml
More file actions
79 lines (66 loc) · 2.85 KB
/
Copy pathissue-triggered-create-jira.yml
File metadata and controls
79 lines (66 loc) · 2.85 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Send GitHub issue data to Jira via tmkv2
on:
issues:
types: [opened]
permissions:
contents: read
jobs:
post_to_api:
runs-on: ubuntu-latest
steps:
- name: Send Issue Data via Signed Curl
env:
API_KEY: ${{ secrets.TMV2_PROD_API_KEY }}
API_ENDPOINT: ${{ secrets.TMV2_PROD_API_ENDPOINT }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_AUTHOR: ${{ github.event.issue.user.login }}
ISSUE_URL: ${{ github.event.issue.html_url }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_BODY: ${{ github.event.issue.body }}
run: |
MAX_ATTEMPTS=4
RETRY_DELAY=120
# Build the JSON body using jq for safe escaping of special characters
BODY=$(jq -n \
--arg title "$ISSUE_TITLE" \
--arg author "$ISSUE_AUTHOR" \
--arg url "$ISSUE_URL" \
--arg number "$ISSUE_NUMBER" \
--arg body "$ISSUE_BODY" \
'{
project: "PQ",
summary: ("New GitHub Issue: " + $title),
description: ("Issue #" + $number + " opened by " + $author + ".\n*URL:* " + $url + ".\n*Body:*\n\n" + $body),
issuetype: "Bug",
labels: ["project-LINK_AI_WALLET"]
}')
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -mac HMAC -macopt hexkey:$API_KEY -binary | openssl base64 -A)
for ATTEMPT in $(seq 1 $MAX_ATTEMPTS); do
echo "--- Attempt $ATTEMPT of $MAX_ATTEMPTS ---"
HTTP_STATUS=$(curl -s -o /tmp/response.txt -w "%{http_code}" \
-X POST "$API_ENDPOINT" \
-H "Content-Type: application/json" \
-H "X-TM-Signature: $SIG" \
--data-raw "$BODY")
echo "HTTP Status: $HTTP_STATUS"
echo "Response: $(cat /tmp/response.txt)"
if [ "$HTTP_STATUS" -ge 200 ] && [ "$HTTP_STATUS" -lt 300 ]; then
echo "Request succeeded on attempt $ATTEMPT."
exit 0
fi
echo "Request failed with HTTP $HTTP_STATUS."
if [ "$ATTEMPT" -lt "$MAX_ATTEMPTS" ]; then
echo "Waiting 15 minutes before retry..."
sleep $RETRY_DELAY
fi
done
echo "All $MAX_ATTEMPTS attempts failed. Marking job as failed."
exit 1
- name: Send Slack Failure Notification via Webhook
if: failure()
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_LINK_PQ_WEBHOOK_URL }}
run: |
curl -s -X POST "$SLACK_WEBHOOK_URL" \
-H "Content-Type: application/json" \
--data-raw '{"text": "❌ ACTION REQUIRED: Jira sync failed for ${{ github.event.issue.html_url }}. Re-run the failed jobs via https://github.com/stripe/link-cli/actions/workflows/issue-triggered-create-jira.yml."}'