Skip to content
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

CLOUDP-284685 Create SDK PRs via apix-bot #3399

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 44 additions & 59 deletions .github/workflows/autoupdate-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: echo "VERSION=$(curl -sSfL -X GET https://api.github.com/repos/mongodb/atlas-sdk-go/releases/latest | jq -r '.tag_name')" >> "$GITHUB_OUTPUT"
- run: make update-atlas-sdk
- name: Verify Changed files
uses: tj-actions/verify-changed-files@530d86d0a237225c87beaa000750988f8965ee31
uses: tj-actions/verify-changed-files@v20.0.1
id: verify-changed-files
with:
files: |
Expand All @@ -30,79 +30,64 @@ jobs:
- name: Find JIRA ticket
id: find
if: steps.verify-changed-files.outputs.files_changed == 'true'
shell: bash
env:
VERSION: ${{ steps.version.outputs.VERSION }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
uses: mongodb/apix-action/find-jira@v4
with:
token: ${{ secrets.JIRA_API_TOKEN }}
jql: project = CLOUDP and summary ~ "Bump Atlas GO SDK to '${{ steps.version.outputs.VERSION }}'"
- name: Set JIRA ticket (find)
if: (steps.verify-changed-files.outputs.files_changed == 'true') && (steps.find.outputs.found == 'true')
run: |
json_response=$(curl --request POST \
--url 'https://jira.mongodb.org/rest/api/2/search' \
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"jql": "project = CLOUDP and summary ~ \"Bump Atlas GO SDK to '"${VERSION}"'\""
}')
echo "Response: ${json_response}"
echo "FOUND=$(echo "${json_response}" | jq -c '[.issues] | flatten | any')" >> "$GITHUB_OUTPUT"
echo "JIRA_KEY=${{steps.find.outputs.issue-key}}" >> "$GITHUB_ENV"
- name: Create JIRA ticket
uses: mongodb/apix-action/create-jira@v4
id: create
if: steps.verify-changed-files.outputs.files_changed == 'true' && steps.find.outputs.FOUND == 'false'
shell: bash
env:
VERSION: ${{ steps.version.outputs.VERSION }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_ASSIGNEE: ${{ secrets.ASSIGNEE_JIRA_TICKET }}
run: |
json_response=$(curl --request POST \
--url 'https://jira.mongodb.org/rest/api/2/issue' \
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
if: (steps.verify-changed-files.outputs.files_changed == 'true') && (steps.find.outputs.found == 'false')
with:
token: ${{ secrets.JIRA_API_TOKEN }}
project-key: CLOUDP
summary: Bump Atlas GO SDK to '${{ steps.version.outputs.VERSION }}'
issuetype: Story
description: Update Atlas GO SDK to '${{ steps.version.outputs.VERSION }}'
components: AtlasCLI
extra-data: |
{
"fields": {
"project": {
"id": "10984"
},
"summary": "Bump Atlas GO SDK to '"${VERSION}"'",
"issuetype": {
"id": "12"
},
"customfield_12751": [{
"id": "22223"
}],
"description": "Update Atlas GO SDK to '"${VERSION}"'.",
"components": [
{
"id": "30450"
}
],
"assignee": {
"name": "'"${JIRA_ASSIGNEE}"'"
"assignee": {
"name": "cloud-atlascli-escalation"
},
"customfield_12751": [
{
"id": "22223"
}
]
}
}')

echo "Response: ${json_response}"

JIRA_TICKET_ID=$(echo "${json_response}" | jq -r '.key')

echo "The following JIRA ticket has been created: ${JIRA_TICKET_ID}"
echo "jira-ticket-id=${JIRA_TICKET_ID}" >> "${GITHUB_OUTPUT}"
}
- name: Set JIRA ticket (create)
if: (steps.verify-changed-files.outputs.files_changed == 'true') && (steps.find.outputs.found == 'false')
run: |
echo "JIRA_KEY=${{steps.create.outputs.issue-key}}" >> "$GITHUB_ENV"
- name: set Apix Bot token
if: steps.verify-changed-files.outputs.files_changed == 'true'
id: app-token
uses: mongodb/apix-action/token@v4
with:
app-id: ${{ secrets.APIXBOT_APP_ID }}
private-key: ${{ secrets.APIXBOT_APP_PEM }}
- uses: peter-evans/create-pull-request@v7
id: pr
if: steps.verify-changed-files.outputs.files_changed == 'true' && steps.find.outputs.FOUND == 'false'
if: steps.verify-changed-files.outputs.files_changed == 'true'
with:
title: "${{ steps.create.outputs.jira-ticket-id }}: Bump Atlas GO SDK to ${{ steps.version.outputs.VERSION }}"
commit-message: "${{ steps.create.outputs.jira-ticket-id }}: Bump Atlas GO SDK to ${{ steps.version.outputs.VERSION }}"
token: ${{ steps.app-token.outputs.token }}
title: "${{ env.JIRA_KEY }}: Bump Atlas GO SDK to ${{ steps.version.outputs.VERSION }}"
commit-message: "${{ env.JIRA_KEY }}: Bump Atlas GO SDK to ${{ steps.version.outputs.VERSION }}"
delete-branch: true
base: master
branch: ${{ steps.create.outputs.jira-ticket-id }}
branch: ${{ env.JIRA_KEY }}
labels: |
dependencies
go
atlas-sdk
body: |
## Proposed changes
Update MongoDB Atlas Go Client SDK to ${{ steps.version.outputs.VERSION }}
_Jira ticket:_ ${{ steps.create.outputs.jira-ticket-id }}
_Jira ticket:_ ${{ env.JIRA_KEY }}