Skip to content

Commit 1fe7105

Browse files
authored
CLOUDP-284685 Create SDK PRs via apix-bot (#3399)
1 parent 1a4b8b6 commit 1fe7105

File tree

1 file changed

+44
-59
lines changed

1 file changed

+44
-59
lines changed

.github/workflows/autoupdate-sdk.yaml

Lines changed: 44 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
run: echo "VERSION=$(curl -sSfL -X GET https://api.github.com/repos/mongodb/atlas-sdk-go/releases/latest | jq -r '.tag_name')" >> "$GITHUB_OUTPUT"
2121
- run: make update-atlas-sdk
2222
- name: Verify Changed files
23-
uses: tj-actions/verify-changed-files@530d86d0a237225c87beaa000750988f8965ee31
23+
uses: tj-actions/verify-changed-files@v20.0.1
2424
id: verify-changed-files
2525
with:
2626
files: |
@@ -30,79 +30,64 @@ jobs:
3030
- name: Find JIRA ticket
3131
id: find
3232
if: steps.verify-changed-files.outputs.files_changed == 'true'
33-
shell: bash
34-
env:
35-
VERSION: ${{ steps.version.outputs.VERSION }}
36-
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
33+
uses: mongodb/apix-action/find-jira@v4
34+
with:
35+
token: ${{ secrets.JIRA_API_TOKEN }}
36+
jql: project = CLOUDP and summary ~ "Bump Atlas GO SDK to '${{ steps.version.outputs.VERSION }}'"
37+
- name: Set JIRA ticket (find)
38+
if: (steps.verify-changed-files.outputs.files_changed == 'true') && (steps.find.outputs.found == 'true')
3739
run: |
38-
json_response=$(curl --request POST \
39-
--url 'https://jira.mongodb.org/rest/api/2/search' \
40-
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
41-
--header 'Accept: application/json' \
42-
--header 'Content-Type: application/json' \
43-
--data '{
44-
"jql": "project = CLOUDP and summary ~ \"Bump Atlas GO SDK to '"${VERSION}"'\""
45-
}')
46-
echo "Response: ${json_response}"
47-
echo "FOUND=$(echo "${json_response}" | jq -c '[.issues] | flatten | any')" >> "$GITHUB_OUTPUT"
40+
echo "JIRA_KEY=${{steps.find.outputs.issue-key}}" >> "$GITHUB_ENV"
4841
- name: Create JIRA ticket
42+
uses: mongodb/apix-action/create-jira@v4
4943
id: create
50-
if: steps.verify-changed-files.outputs.files_changed == 'true' && steps.find.outputs.FOUND == 'false'
51-
shell: bash
52-
env:
53-
VERSION: ${{ steps.version.outputs.VERSION }}
54-
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
55-
JIRA_ASSIGNEE: ${{ secrets.ASSIGNEE_JIRA_TICKET }}
56-
run: |
57-
json_response=$(curl --request POST \
58-
--url 'https://jira.mongodb.org/rest/api/2/issue' \
59-
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
60-
--header 'Accept: application/json' \
61-
--header 'Content-Type: application/json' \
62-
--data '{
44+
if: (steps.verify-changed-files.outputs.files_changed == 'true') && (steps.find.outputs.found == 'false')
45+
with:
46+
token: ${{ secrets.JIRA_API_TOKEN }}
47+
project-key: CLOUDP
48+
summary: Bump Atlas GO SDK to '${{ steps.version.outputs.VERSION }}'
49+
issuetype: Story
50+
description: Update Atlas GO SDK to '${{ steps.version.outputs.VERSION }}'
51+
components: AtlasCLI
52+
extra-data: |
53+
{
6354
"fields": {
64-
"project": {
65-
"id": "10984"
66-
},
67-
"summary": "Bump Atlas GO SDK to '"${VERSION}"'",
68-
"issuetype": {
69-
"id": "12"
70-
},
71-
"customfield_12751": [{
72-
"id": "22223"
73-
}],
74-
"description": "Update Atlas GO SDK to '"${VERSION}"'.",
75-
"components": [
76-
{
77-
"id": "30450"
78-
}
79-
],
80-
"assignee": {
81-
"name": "'"${JIRA_ASSIGNEE}"'"
55+
"assignee": {
56+
"name": "cloud-atlascli-escalation"
57+
},
58+
"customfield_12751": [
59+
{
60+
"id": "22223"
8261
}
62+
]
8363
}
84-
}')
85-
86-
echo "Response: ${json_response}"
87-
88-
JIRA_TICKET_ID=$(echo "${json_response}" | jq -r '.key')
89-
90-
echo "The following JIRA ticket has been created: ${JIRA_TICKET_ID}"
91-
echo "jira-ticket-id=${JIRA_TICKET_ID}" >> "${GITHUB_OUTPUT}"
64+
}
65+
- name: Set JIRA ticket (create)
66+
if: (steps.verify-changed-files.outputs.files_changed == 'true') && (steps.find.outputs.found == 'false')
67+
run: |
68+
echo "JIRA_KEY=${{steps.create.outputs.issue-key}}" >> "$GITHUB_ENV"
69+
- name: set Apix Bot token
70+
if: steps.verify-changed-files.outputs.files_changed == 'true'
71+
id: app-token
72+
uses: mongodb/apix-action/token@v4
73+
with:
74+
app-id: ${{ secrets.APIXBOT_APP_ID }}
75+
private-key: ${{ secrets.APIXBOT_APP_PEM }}
9276
- uses: peter-evans/create-pull-request@v7
9377
id: pr
94-
if: steps.verify-changed-files.outputs.files_changed == 'true' && steps.find.outputs.FOUND == 'false'
78+
if: steps.verify-changed-files.outputs.files_changed == 'true'
9579
with:
96-
title: "${{ steps.create.outputs.jira-ticket-id }}: Bump Atlas GO SDK to ${{ steps.version.outputs.VERSION }}"
97-
commit-message: "${{ steps.create.outputs.jira-ticket-id }}: Bump Atlas GO SDK to ${{ steps.version.outputs.VERSION }}"
80+
token: ${{ steps.app-token.outputs.token }}
81+
title: "${{ env.JIRA_KEY }}: Bump Atlas GO SDK to ${{ steps.version.outputs.VERSION }}"
82+
commit-message: "${{ env.JIRA_KEY }}: Bump Atlas GO SDK to ${{ steps.version.outputs.VERSION }}"
9883
delete-branch: true
9984
base: master
100-
branch: ${{ steps.create.outputs.jira-ticket-id }}
85+
branch: ${{ env.JIRA_KEY }}
10186
labels: |
10287
dependencies
10388
go
10489
atlas-sdk
10590
body: |
10691
## Proposed changes
10792
Update MongoDB Atlas Go Client SDK to ${{ steps.version.outputs.VERSION }}
108-
_Jira ticket:_ ${{ steps.create.outputs.jira-ticket-id }}
93+
_Jira ticket:_ ${{ env.JIRA_KEY }}

0 commit comments

Comments
 (0)