-
Notifications
You must be signed in to change notification settings - Fork 14
SNOW-2069227: Update Jira workflows #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
a7c0655
6c4a2d3
20bf9c1
3471f00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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/[email protected] | ||
| - 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") | ||
sfc-gh-hpathak marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - name: Create JIRA Ticket | ||
| id: create | ||
| uses: atlassian/[email protected] | ||
| 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 }})" | ||
| }' | ||
Uh oh!
There was an error while loading. Please reload this page.