Skip to content

Commit 972205e

Browse files
CLOUDP-308778: Onboard cobra2snooty to jira apix automations (#73)
1 parent 1d96502 commit 972205e

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

.github/workflows/close-jira.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Auto Close Jira
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
7+
jobs:
8+
close-jira:
9+
name: close jira
10+
runs-on: ubuntu-latest
11+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'auto_close_jira')
12+
steps:
13+
- name: set jira key (branch name)
14+
if: ${{ startsWith(github.event.pull_request.head.ref, 'CLOUDP') }}
15+
env:
16+
REF: ${{ github.event.pull_request.head.ref }}
17+
run: echo "JIRA_KEY=$REF" >> "$GITHUB_ENV"
18+
- name: set jira key (comment)
19+
if: ${{ !startsWith(github.event.pull_request.head.ref, 'CLOUDP') }}
20+
env:
21+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
22+
URL: ${{ github.event.pull_request.html_url }}
23+
run: |
24+
JIRA_KEY=$(gh pr view "$URL" --comments | grep 'was created for internal tracking' | grep -oE 'CLOUDP-[0-9]+' | head -1)
25+
echo "JIRA_KEY=$JIRA_KEY" >> "$GITHUB_ENV"
26+
- name: Close JIRA ticket
27+
uses: mongodb/apix-action/transition-jira@v8
28+
with:
29+
token: ${{ secrets.JIRA_API_TOKEN }}
30+
issue-key: ${{ env.JIRA_KEY }}
31+
transition-id: 1381 # Resolved
32+
resolution: Fixed

.github/workflows/dependabot.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
name: Create JIRA ticket for dependabot prs
3+
4+
on:
5+
pull_request:
6+
types: [opened]
7+
8+
permissions:
9+
pull-requests: write
10+
contents: write
11+
repository-projects: read
12+
jobs:
13+
jira_task:
14+
name: Create Jira issue
15+
runs-on: ubuntu-latest
16+
if: github.actor == 'dependabot[bot]'
17+
steps:
18+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
19+
with:
20+
config: ${{ vars.PERMISSIONS_CONFIG }}
21+
- name: Checkout code
22+
uses: actions/[email protected]
23+
with:
24+
fetch-depth: 2
25+
- name: set Apix Bot token
26+
id: app-token
27+
uses: mongodb/apix-action/token@3024080388613583e3bd119bfb1ab4b4dbf43c42
28+
with:
29+
app-id: ${{ secrets.APIXBOT_APP_ID }}
30+
private-key: ${{ secrets.APIXBOT_APP_PEM }}
31+
- name: Create JIRA ticket
32+
uses: mongodb/apix-action/create-jira@v8
33+
id: create
34+
with:
35+
token: ${{ secrets.JIRA_API_TOKEN }}
36+
project-key: CLOUDP
37+
summary: cobra2snooty Dependency Update n. ${{ github.event.pull_request.number }}
38+
issuetype: Story
39+
description: "This ticket tracks the following GitHub pull request: ${{ github.event.pull_request.html_url }}."
40+
components: AtlasCLI
41+
assignee: ${{ secrets.ASSIGNEE_JIRA_TICKET }}
42+
extra-data: |
43+
{
44+
"fields": {
45+
"fixVersions": [
46+
{
47+
"id": "41805"
48+
}
49+
],
50+
"customfield_12751": [
51+
{
52+
"id": "${{ vars.JIRA_TEAM_APIX_2 }}"
53+
}
54+
],
55+
"customfield_10257": {
56+
"id": "11861"
57+
}
58+
}
59+
}
60+
- name: Add comment
61+
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
62+
with:
63+
issue-number: ${{ github.event.pull_request.number }}
64+
body: |
65+
The ticket [${{ steps.create.outputs.issue-key }}](https://jira.mongodb.org/browse/${{ steps.create.outputs.issue-key }}) was created for internal tracking.
66+
67+
Note: Jira ticket will be closed automatically when this PR is merged.
68+
- name: Add auto_close_jira label
69+
env:
70+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: |
72+
gh pr edit "${{github.event.pull_request.html_url}}" --add-label "auto_close_jira"
73+
- name: Set auto merge
74+
env:
75+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
76+
run: |
77+
gh pr merge "${{ github.event.pull_request.html_url }}" --auto --squash

0 commit comments

Comments
 (0)