@@ -19,28 +19,28 @@ jobs:
1919 JIRA_BASE_URL : ${{ secrets.JIRA_BASE_URL }}
2020 JIRA_USER_EMAIL : ${{ secrets.JIRA_USER_EMAIL }}
2121 JIRA_API_TOKEN : ${{ secrets.JIRA_API_TOKEN }}
22- ISSUE_TITLE : ${{ github.event.issue.title }}
23- ISSUE_BODY : ${{ github.event.issue.body }}
2422 ISSUE_URL : ${{ github.event.issue.html_url }}
2523 run : |
2624 # Escape special characters in title and body
27- TITLE=$(echo "$ISSUE_TITLE" | sed 's/"/\\"/g' | sed "s/'/\\\'/g")
28- BODY=$(echo "$ISSUE_BODY" | sed 's/"/\\"/g' | sed "s/'/\\\'/g")
29- PAYLOAD=$(cat <<EOF
30- {
31- "fields": {
32- "project": { "key": "SNOW" },
33- "issuetype": { "name": "Bug" },
34- "summary": "$TITLE",
35- "description": "$BODY\n\n_Created from GitHub Action_ for $ISSUE_URL",
36- "customfield_11401": {"id": "14723"},
37- "assignee": {"id": "712020:e527ae71-55cc-4e02-9217-1ca4ca8028a2"},
38- "components": [{"id": "16413"}],
39- "labels": ["oss"],
40- "priority": {"id": "10001"}
25+ TITLE=$(echo '${{ github.event.issue.title }}' | sed 's/"/\\"/g' | sed "s/'/\\\'/g")
26+ BODY=$(echo '${{ github.event.issue.body }}' | sed 's/"/\\"/g' | sed "s/'/\\\'/g")
27+ PAYLOAD=$(jq -n \
28+ --arg issuetitle "$TITLE" \
29+ --arg issuebody "$BODY" \
30+ --arg issueurl "$ISSUE_URL" \
31+ '{
32+ fields: {
33+ project: { key: "SNOW" },
34+ issuetype: { name: "Bug" },
35+ summary: $issuetitle,
36+ description: ($issuebody + "\n\n_Created from GitHub Action_ for " + $issueurl),
37+ customfield_11401: { id: "14723" },
38+ assignee: { id: "712020:e527ae71-55cc-4e02-9217-1ca4ca8028a2" },
39+ components: [{ id: "16413" }],
40+ labels: ["oss"],
41+ priority: { id: "10001" }
4142 }
42- }
43- )
43+ }')
4444
4545 # Create JIRA issue using REST API
4646 RESPONSE=$(curl -s -X POST \
5656 if [ "$JIRA_KEY" = "null" ] || [ -z "$JIRA_KEY" ]; then
5757 echo "Failed to create JIRA issue"
5858 echo "Response: $RESPONSE"
59+ echo "Request payload: $PAYLOAD"
5960 exit 1
6061 fi
6162
@@ -71,10 +72,10 @@ jobs:
7172 ISSUE_TITLE : ${{ github.event.issue.title }}
7273 run : |
7374 # Update Github issue title with jira id
74- curl -s \
75+ GH_UPD_RESPONSE=$( curl -s \
7576 -X PATCH \
7677 -H "Authorization: Bearer $GITHUB_TOKEN" \
7778 -H "Accept: application/vnd.github+json" \
7879 -H "X-GitHub-Api-Version: 2022-11-28" \
7980 "https://api.github.com/repos/$REPOSITORY/issues/$ISSUE_NUMBER" \
80- -d "{\"title\":\"$JIRA_KEY: $ISSUE_TITLE\"}"
81+ -d "{\"title\":\"$JIRA_KEY: $ISSUE_TITLE\"}")
0 commit comments