Skip to content

Commit bf370b0

Browse files
NO-SNOW fix jira creation + closure workflows (#1289)
1 parent 763aca7 commit bf370b0

File tree

3 files changed

+148
-86
lines changed

3 files changed

+148
-86
lines changed

.github/ISSUE_TEMPLATE/BUG_REPORT.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,22 @@ about: Something isn't working as expected? Here is the right place to report.
44
labels: bug
55
---
66

7+
:exclamation: If you need **urgent assistance** then [file a case with Snowflake Support](https://community.snowflake.com/s/article/How-To-Submit-a-Support-Case-in-Snowflake-Lodge).
8+
Otherwise continue here.
79

8-
<!--
9-
If you need urgent assistance then file the issue using the support process:
10-
https://community.snowflake.com/s/article/How-To-Submit-a-Support-Case-in-Snowflake-Lodge
11-
otherwise continue here.
12-
-->
1310

14-
15-
Please answer these questions before submitting your issue.
11+
Please answer these questions before submitting your issue.
1612
In order to accurately debug the issue this information is required. Thanks!
1713

1814
1. What version of .NET driver are you using?
1915

20-
16+
2117
2. What operating system and processor architecture are you using?
2218

23-
19+
2420
3. What version of .NET framework are you using?
2521
E.g. .net framework 4.5.2 or .net standard 2.0
26-
22+
2723
4. What did you do?
2824

2925
If possible, provide a recipe for reproducing the error.
@@ -36,7 +32,7 @@ In order to accurately debug the issue this information is required. Thanks!
3632
6. Can you set logging to DEBUG and collect the logs?
3733

3834
https://community.snowflake.com/s/article/How-to-generate-log-file-on-Snowflake-connectors
39-
35+
4036
There is an example in READMD.md file showing you how to enable logging.
4137

4238
Before sharing any information, please be sure to review the log and remove any sensitive

.github/workflows/jira_close.yml

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,47 @@
11
name: Jira closure
22

33
on:
4-
issues:
5-
types: [closed, deleted]
4+
issues:
5+
types: [closed, deleted]
66

77
jobs:
8-
close-issue:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- name: Checkout
12-
uses: actions/checkout@v4
13-
with:
14-
repository: snowflakedb/gh-actions
15-
ref: jira_v1
16-
token: ${{ secrets.SNOWFLAKE_GITHUB_TOKEN }} # stored in GitHub secrets
17-
path: .
18-
- name: Jira login
19-
uses: atlassian/gajira-login@v3
20-
env:
21-
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
22-
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
23-
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
24-
- name: Extract issue from title
25-
id: extract
26-
env:
27-
TITLE: "${{ github.event.issue.title }}"
28-
run: |
29-
jira=$(echo -n $TITLE | awk '{print $1}' | sed -e 's/://')
30-
echo ::set-output name=jira::$jira
31-
- name: Close issue
32-
uses: ./jira/gajira-close
33-
if: startsWith(steps.extract.outputs.jira, 'SNOW-')
34-
with:
35-
issue: "${{ steps.extract.outputs.jira }}"
8+
close-issue:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Extract issue from title
12+
id: extract
13+
env:
14+
TITLE: '${{ github.event.issue.title }}'
15+
run: |
16+
jira=$(echo -n $TITLE | awk '{print $1}' | sed -e 's/://')
17+
echo ::set-output name=jira::$jira
18+
19+
- name: Close Jira Issue
20+
if: startsWith(steps.extract.outputs.jira, 'SNOW-')
21+
env:
22+
ISSUE_KEY: ${{ steps.extract.outputs.jira }}
23+
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
24+
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
25+
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
26+
run: |
27+
JIRA_API_URL="${JIRA_BASE_URL}/rest/api/2/issue/${ISSUE_KEY}/transitions"
28+
29+
curl -X POST \
30+
--url "$JIRA_API_URL" \
31+
--user "${JIRA_USER_EMAIL}:${JIRA_API_TOKEN}" \
32+
--header "Content-Type: application/json" \
33+
--data "{
34+
\"update\": {
35+
\"comment\": [
36+
{ \"add\": { \"body\": \"Closed on GitHub\" } }
37+
]
38+
},
39+
\"fields\": {
40+
\"customfield_12860\": { \"id\": \"11506\" },
41+
\"customfield_10800\": { \"id\": \"-1\" },
42+
\"customfield_12500\": { \"id\": \"11302\" },
43+
\"customfield_12400\": { \"id\": \"-1\" },
44+
\"resolution\": { \"name\": \"Done\" }
45+
},
46+
\"transition\": { \"id\": \"71\" }
47+
}"

.github/workflows/jira_issue.yml

Lines changed: 99 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,104 @@
11
name: Jira creation
22

33
on:
4-
issues:
5-
types: [opened]
6-
issue_comment:
7-
types: [created]
4+
issues:
5+
types: [opened]
6+
issue_comment:
7+
types: [created]
88

99
jobs:
10-
create-issue:
11-
runs-on: ubuntu-latest
12-
permissions:
13-
issues: write
14-
if: ((github.event_name == 'issue_comment' && github.event.comment.body == 'recreate jira' && github.event.comment.user.login == 'sfc-gh-mkeller') || (github.event_name == 'issues' && github.event.pull_request.user.login != 'whitesource-for-github-com[bot]'))
15-
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v4
18-
with:
19-
repository: snowflakedb/gh-actions
20-
ref: jira_v1
21-
token: ${{ secrets.SNOWFLAKE_GITHUB_TOKEN }} # stored in GitHub secrets
22-
path: .
23-
24-
- name: Login
25-
uses: atlassian/gajira-login@v3
26-
env:
27-
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
28-
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
29-
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
30-
31-
- name: Create JIRA Ticket
32-
id: create
33-
uses: atlassian/gajira-create@v3
34-
with:
35-
project: SNOW
36-
issuetype: Bug
37-
summary: '${{ github.event.issue.title }}'
38-
description: |
39-
${{ github.event.issue.body }} \\ \\ _Created from GitHub Action_ for ${{ github.event.issue.html_url }}
40-
fields: '{ "customfield_11401": {"id": "14723"}, "assignee": {"id": "712020:e527ae71-55cc-4e02-9217-1ca4ca8028a2"}, "components":[{"id":"19287"}], "labels": ["oss"], "priority": {"id": "10001"} }'
41-
42-
- name: Update GitHub Issue
43-
uses: ./jira/gajira-issue-update
44-
env:
45-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46-
with:
47-
issue_number: "{{ event.issue.id }}"
48-
owner: "{{ event.repository.owner.login }}"
49-
name: "{{ event.repository.name }}"
50-
jira: "${{ steps.create.outputs.issue }}"
10+
create-issue:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
issues: write
14+
if: ((github.event_name == 'issue_comment' && github.event.comment.body == 'recreate jira' && github.event.comment.user.login == 'sfc-gh-mkeller') || (github.event_name == 'issues' && github.event.pull_request.user.login != 'whitesource-for-github-com[bot]'))
15+
steps:
16+
- name: Create JIRA Ticket
17+
id: create
18+
env:
19+
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
20+
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
21+
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
22+
ISSUE_TITLE: ${{ github.event.issue.title }}
23+
ISSUE_BODY: ${{ github.event.issue.body }}
24+
ISSUE_URL: ${{ github.event.issue.html_url }}
25+
run: |
26+
# debug
27+
#set -x
28+
TMP_BODY=$(mktemp)
29+
trap "rm -f $TMP_BODY" EXIT
30+
31+
# Escape special characters in title and body
32+
TITLE=$(echo "${ISSUE_TITLE//`/\\`}" | sed 's/"/\\"/g' | sed "s/'/\\\'/g")
33+
echo "${ISSUE_BODY//`/\\`}" | sed 's/"/\\"/g' | sed "s/'/\\\'/g" > $TMP_BODY
34+
echo -e "\n\n_Created from GitHub Action_ for $ISSUE_URL" >> $TMP_BODY
35+
BODY=$(cat "$TMP_BODY")
36+
37+
PAYLOAD=$(jq -n \
38+
--arg issuetitle "$TITLE" \
39+
--arg issuebody "$BODY" \
40+
'{
41+
fields: {
42+
project: { key: "SNOW" },
43+
issuetype: { name: "Bug" },
44+
summary: $issuetitle,
45+
description: $issuebody,
46+
customfield_11401: { id: "14723" },
47+
assignee: { id: "712020:e527ae71-55cc-4e02-9217-1ca4ca8028a2" },
48+
components: [{ id: "19287" }],
49+
labels: ["oss"],
50+
priority: { id: "10001" }
51+
}
52+
}')
53+
54+
# Create JIRA issue using REST API
55+
RESPONSE=$(curl -s -X POST \
56+
-H "Content-Type: application/json" \
57+
-H "Accept: application/json" \
58+
-u "$JIRA_USER_EMAIL:$JIRA_API_TOKEN" \
59+
"$JIRA_BASE_URL/rest/api/2/issue" \
60+
-d "$PAYLOAD")
61+
62+
# Extract JIRA issue key from response
63+
JIRA_KEY=$(echo "$RESPONSE" | jq -r '.key')
64+
65+
if [ "$JIRA_KEY" = "null" ] || [ -z "$JIRA_KEY" ]; then
66+
echo "Failed to create JIRA issue"
67+
echo "Response: $RESPONSE"
68+
echo "Request payload: $PAYLOAD"
69+
exit 1
70+
fi
71+
72+
echo "Created JIRA issue: $JIRA_KEY"
73+
echo "jira_key=$JIRA_KEY" >> $GITHUB_OUTPUT
74+
75+
- name: Update GitHub Issue
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
REPOSITORY: ${{ github.repository }}
79+
ISSUE_NUMBER: ${{ github.event.issue.number }}
80+
JIRA_KEY: ${{ steps.create.outputs.jira_key }}
81+
ISSUE_TITLE: ${{ github.event.issue.title }}
82+
run: |
83+
TITLE=$(echo "${ISSUE_TITLE//`/\\`}" | sed 's/"/\\"/g' | sed "s/'/\\\'/g")
84+
PAYLOAD=$(jq -n \
85+
--arg issuetitle "$TITLE" \
86+
--arg jirakey "$JIRA_KEY" \
87+
'{
88+
title: ($jirakey + ": " + $issuetitle)
89+
}')
90+
91+
# Update Github issue title with jira id
92+
curl -s \
93+
-X PATCH \
94+
-H "Authorization: Bearer $GITHUB_TOKEN" \
95+
-H "Accept: application/vnd.github+json" \
96+
-H "X-GitHub-Api-Version: 2022-11-28" \
97+
"https://api.github.com/repos/$REPOSITORY/issues/$ISSUE_NUMBER" \
98+
-d "$PAYLOAD"
99+
100+
if [ "$?" != 0 ]; then
101+
echo "Failed to update GH issue. Payload was:"
102+
echo "$PAYLOAD"
103+
exit 1
104+
fi

0 commit comments

Comments
 (0)