1414 id : extract-type
1515 run : |
1616 # Extract issue type from GitHub labels
17- ISSUE_TYPE="Task " # Default type
17+ ISSUE_TYPE="Bug " # Default type
1818 LABELS="${{ join(github.event.issue.labels.*.name, ',') }}"
1919
2020 if [[ "$LABELS" == *"bug"* ]] || [[ "$LABELS" == *"Bug"* ]]; then
@@ -31,46 +31,52 @@ jobs:
3131 - name : Create Jira Task
3232 run : |
3333 # Create Jira issue using REST API
34- ISSUE_DESCRIPTION="*GitHub Issue created by:* ${{ github.event.issue.user.login }}
35- *Repository:* ${{ github.repository }}
36- *Issue URL:* ${{ github.event.issue.html_url }}
37- *Labels:* ${{ steps.extract-type.outputs.labels }}
34+ # Create a temporary file for the JSON payload to handle proper escaping
35+ cat > /tmp/jira_payload.json << 'EOF'
36+ {
37+ "fields": {
38+ "project": {
39+ "key": "${{ secrets.JIRA_PROJECT_KEY }}"
40+ },
41+ "issuetype": {
42+ "name": "${{ steps.extract-type.outputs.issue_type }}"
43+ },
44+ "summary": "[xperience-by-kentico-tag-manager] ${{ github.event.issue.title }}",
45+ "assignee": {
46+ "accountId": "${{ secrets.JIRA_ASSIGNEE_ACCOUNT_ID }}"
47+ },
48+ "description": {
49+ "type": "doc",
50+ "version": 1,
51+ "content": [
52+ {
53+ "type": "paragraph",
54+ "content": [
55+ {
56+ "type": "text",
57+ "text": "GitHub Issue created by: ${{ github.event.issue.user.login }}\nRepository: ${{ github.repository }}\nIssue URL: ${{ github.event.issue.html_url }}\nLabels: ${{ steps.extract-type.outputs.labels }}\n\n---\n\n"
58+ }
59+ ]
60+ }
61+ ]
62+ }
63+ }
64+ }
65+ EOF
3866
39- ---
67+ # Add the issue body as a separate paragraph to avoid JSON escaping issues
68+ # Use jq to properly escape and add the issue body
69+ ISSUE_BODY=$(echo '${{ github.event.issue.body }}' | jq -Rs .)
4070
41- ${{ github.event.issue.body }}"
71+ # Update the JSON payload with the properly escaped issue body
72+ jq --argjson body "$ISSUE_BODY" \
73+ '.fields.description.content += [{"type": "paragraph", "content": [{"type": "text", "text": $body}]}]' \
74+ /tmp/jira_payload.json > /tmp/jira_payload_final.json
4275
76+ # Make the API call with the properly formatted JSON
4377 curl -X POST \
4478 -H "Accept: application/json" \
4579 -H "Content-Type: application/json" \
4680 -u "${{ secrets.JIRA_USER_EMAIL }}:${{ secrets.JIRA_API_TOKEN }}" \
47- -d '{
48- "fields": {
49- "project": {
50- "key": "${{ secrets.JIRA_PROJECT_KEY }}"
51- },
52- "issuetype": {
53- "name": "${{ steps.extract-type.outputs.issue_type }}"
54- },
55- "summary": "[xperience-by-kentico-tag-manager] ${{ github.event.issue.title }}",
56- "assignee": {
57- "accountId": "${{ secrets.JIRA_ASSIGNEE_ACCOUNT_ID }}"
58- },
59- "description": {
60- "type": "doc",
61- "version": 1,
62- "content": [
63- {
64- "type": "paragraph",
65- "content": [
66- {
67- "type": "text",
68- "text": "'"${ISSUE_DESCRIPTION}"'"
69- }
70- ]
71- }
72- ]
73- }
74- }
75- }' \
81+ -d @/tmp/jira_payload_final.json \
7682 "${{ secrets.JIRA_BASE_URL }}/rest/api/3/issue"
0 commit comments