File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Add Comment to Jira Issue
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ jira_key :
7+ description : " The Jira issue key (e.g. STAG-17)"
8+ required : true
9+ type : string
10+ comment :
11+ description : " The comment text to add to the issue"
12+ required : true
13+ type : string
14+ secrets :
15+ jira_auth :
16+ description : ' Plain "email:api_token" for Jira Cloud Basic auth'
17+ required : true
18+
19+ jobs :
20+ add_comment :
21+ runs-on : ubuntu-latest
22+ env :
23+ JIRA_BASE_URL : https://scylladb.atlassian.net
24+ JIRA_KEY : ${{ inputs.jira_key }}
25+ COMMENT_RAW : ${{ inputs.comment }}
26+ JIRA_AUTH : ${{ secrets.jira_auth }}
27+
28+ steps :
29+ - name : Post comment to Jira issue
30+ shell : bash
31+ run : |
32+ set -euo pipefail
33+
34+ if [ -z "$JIRA_KEY" ]; then
35+ echo "JIRA_KEY is empty; nothing to do."
36+ exit 0
37+ fi
38+
39+ echo "Adding comment to Jira issue: $JIRA_KEY"
40+
41+ # Safely JSON-encode the comment text
42+ COMMENT_JSON=$(printf '%s' "$COMMENT_RAW" | jq -Rs .)
43+
44+ # Build JSON payload: { "body": "<comment>" }
45+ PAYLOAD=$(jq -n --arg body "$COMMENT_RAW" '{body: $body}')
46+
47+ ISSUE_URL="${JIRA_BASE_URL}/rest/api/3/issue/${JIRA_KEY}/comment"
48+
49+ curl -sS --fail \
50+ --user "$JIRA_AUTH" \
51+ -H "Accept: application/json" \
52+ -H "Content-Type: application/json" \
53+ -X POST "$ISSUE_URL" \
54+ --data "$PAYLOAD"
55+
56+ echo "Comment added to $JIRA_KEY"
You can’t perform that action at this time.
0 commit comments