From a7c0655f381fe0420366ce712c52407ab2fc9653 Mon Sep 17 00:00:00 2001 From: Harsh Pathak Date: Mon, 25 Aug 2025 17:25:28 -0700 Subject: [PATCH 1/4] Update .github/workflows/jira_close.yml to use curl and avoid repo dependency. --- .github/workflows/jira_close.yml | 51 +++++++++++++++++++------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/.github/workflows/jira_close.yml b/.github/workflows/jira_close.yml index 8b0fe7c2..15d22e1b 100644 --- a/.github/workflows/jira_close.yml +++ b/.github/workflows/jira_close.yml @@ -1,4 +1,3 @@ ---- name: Jira closure on: @@ -11,28 +10,40 @@ jobs: close-issue: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 - with: - repository: snowflakedb/gh-actions - ref: jira_v1 - token: ${{ secrets.SNOWFLAKE_GITHUB_TOKEN }} # stored in GitHub secrets - path: . - - name: Jira login - uses: atlassian/gajira-login@master - env: - JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} - JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} - JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} - name: Extract issue from title id: extract env: - TITLE: ${{ github.event.issue.title }} - run: | + TITLE: "${{ github.event.issue.title }}" + run: |- jira=$(echo -n $TITLE | awk '{print $1}' | sed -e 's/://') echo ::set-output name=jira::$jira - - name: Close issue - uses: ./jira/gajira-close + + - name: Close Jira Issue if: startsWith(steps.extract.outputs.jira, 'SNOW-') - with: - issue: ${{ steps.extract.outputs.jira }} + env: + ISSUE_KEY: ${{ steps.extract.outputs.jira }} + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} + run: | + JIRA_API_URL="${JIRA_BASE_URL}/rest/api/2/issue/${ISSUE_KEY}/transitions" + + curl -X POST \ + --url "$JIRA_API_URL" \ + --user "${JIRA_USER_EMAIL}:${JIRA_API_TOKEN}" \ + --header "Content-Type: application/json" \ + --data '{ + "update": { + "comment": [ + { "add": { "body": "Closed on GitHub" } } + ] + }, + "fields": { + "customfield_12860": { "id": "11506" }, + "customfield_10800": { "id": "-1" }, + "customfield_12500": { "id": "11302" }, + "customfield_12400": { "id": "-1" }, + "resolution": { "name": "Done" } + }, + "transition": { "id": "71" } + }' From 6c4a2d3bd3a08a5603273b899c639b0e74a2971e Mon Sep 17 00:00:00 2001 From: Harsh Pathak Date: Mon, 25 Aug 2025 17:25:30 -0700 Subject: [PATCH 2/4] Update .github/workflows/jira_issue.yml to use curl and avoid repo dependency. --- .github/workflows/jira_issue.yml | 79 ++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 29 deletions(-) diff --git a/.github/workflows/jira_issue.yml b/.github/workflows/jira_issue.yml index 8480a858..f6c3a6f4 100644 --- a/.github/workflows/jira_issue.yml +++ b/.github/workflows/jira_issue.yml @@ -1,4 +1,3 @@ ---- name: Jira creation on: @@ -16,40 +15,62 @@ jobs: issues: write if: (github.event_name == 'issues' && github.event.pull_request.user.login != 'whitesource-for-github-com[bot]') steps: - - name: Checkout - uses: actions/checkout@v2 - with: - repository: snowflakedb/gh-actions - ref: jira_v1 - token: ${{ secrets.SNOWFLAKE_GITHUB_TOKEN }} # stored in GitHub secrets - path: . - - - name: Login - uses: atlassian/gajira-login@v2.0.0 + - name: Create JIRA Ticket + id: create env: JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} + run: | + # Escape special characters in title and body + TITLE=$(echo '${{ github.event.issue.title }}' | sed 's/"/\\"/g' | sed "s/'/\\\'/g") + BODY=$(echo '${{ github.event.issue.body }}' | sed 's/"/\\"/g' | sed "s/'/\\\'/g") - - name: Create JIRA Ticket - id: create - uses: atlassian/gajira-create@v2.0.1 - with: - project: SNOW - issuetype: Bug - summary: ${{ github.event.issue.title }} - description: | - ${{ github.event.issue.body }} \\ \\ _Created from GitHub Action_ for ${{ github.event.issue.html_url }} - # Assign triage-ml-platform-dl and set "ML Platform" component (19112). - # See https://snowflakecomputing.atlassian.net/rest/api/2/project/SNOW/components for component information. - fields: '{"customfield_11401":{"id":"14538"}, "assignee":{"id":"639020ab3c26ca7fa0d6eb3f"},"components":[{"id":"19112"}]}' + # Create JIRA issue using REST API + RESPONSE=$(curl -s -X POST \ + -H "Content-Type: application/json" \ + -H "Accept: application/json" \ + -u "$JIRA_USER_EMAIL:$JIRA_API_TOKEN" \ + "$JIRA_BASE_URL/rest/api/2/issue" \ + -d '{ + "fields": { + "project": { + "key": "SNOW" + }, + "issuetype": { + "name": "Bug" + }, + "summary": "'"$TITLE"'", + "description": "'"$BODY"' \\\\ \\\\ _Created from GitHub Action_ for ${{ github.event.issue.html_url }}", + "customfield_11401": {"id": "14723"}, + "assignee": {"id": "712020:e527ae71-55cc-4e02-9217-1ca4ca8028a2"}, + "components": [{"id": "19292"}], + "labels": ["oss"], + "priority": {"id": "10001"} + } + }') + + # Extract JIRA issue key from response + JIRA_KEY=$(echo "$RESPONSE" | jq -r '.key') + + if [ "$JIRA_KEY" = "null" ] || [ -z "$JIRA_KEY" ]; then + echo "Failed to create JIRA issue" + echo "Response: $RESPONSE" + exit 1 + fi + + echo "Created JIRA issue: $JIRA_KEY" + echo "jira_key=$JIRA_KEY" >> $GITHUB_OUTPUT - name: Update GitHub Issue - uses: ./jira/gajira-issue-update env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - issue_number: '{{ event.issue.id }}' - owner: '{{ event.repository.owner.login }}' - name: '{{ event.repository.name }}' - jira: ${{ steps.create.outputs.issue }} + run: | + # Add comment to GitHub issue with JIRA link + curl -s -X POST \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments" \ + -d '{ + "body": "JIRA ticket created: [${{ steps.create.outputs.jira_key }}](${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.create.outputs.jira_key }})" + }' From 20bf9c17154f9590eb7dcf95b26f2c670a454907 Mon Sep 17 00:00:00 2001 From: Harsh Pathak Date: Mon, 25 Aug 2025 18:35:36 -0700 Subject: [PATCH 3/4] Update .github/workflows/jira_close.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/jira_close.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/jira_close.yml b/.github/workflows/jira_close.yml index 15d22e1b..c5047dfb 100644 --- a/.github/workflows/jira_close.yml +++ b/.github/workflows/jira_close.yml @@ -13,9 +13,7 @@ jobs: - name: Extract issue from title id: extract env: - TITLE: "${{ github.event.issue.title }}" - run: |- - jira=$(echo -n $TITLE | awk '{print $1}' | sed -e 's/://') + jira=$(echo -n "$TITLE" | awk '{print $1}' | sed -e 's/://') echo ::set-output name=jira::$jira - name: Close Jira Issue From 3471f003dca9384e914d17dc895e1bbbf5198bc0 Mon Sep 17 00:00:00 2001 From: Harsh Pathak Date: Mon, 25 Aug 2025 18:35:50 -0700 Subject: [PATCH 4/4] Update .github/workflows/jira_issue.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/jira_issue.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jira_issue.yml b/.github/workflows/jira_issue.yml index f6c3a6f4..eda0eec3 100644 --- a/.github/workflows/jira_issue.yml +++ b/.github/workflows/jira_issue.yml @@ -22,9 +22,9 @@ jobs: JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} run: | - # Escape special characters in title and body - TITLE=$(echo '${{ github.event.issue.title }}' | sed 's/"/\\"/g' | sed "s/'/\\\'/g") - BODY=$(echo '${{ github.event.issue.body }}' | sed 's/"/\\"/g' | sed "s/'/\\\'/g") + # Properly JSON-encode special characters in title and body using jq + TITLE=$(printf '%s' "${{ github.event.issue.title }}" | jq -Rs .) + BODY=$(printf '%s' "${{ github.event.issue.body }}" | jq -Rs .) # Create JIRA issue using REST API RESPONSE=$(curl -s -X POST \