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-240677 Update SDK update process to handle minor versions and create jiras #2825

Merged
merged 13 commits into from
Apr 5, 2024
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ updates:
open-pull-requests-limit: 20
reviewers:
- "mongodb/mongocli"
ignore:
- dependency-name: "go.mongodb.org/atlas-sdk/*"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignoring on dependabot

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actualy I'm not sure that we should do this. Do we have other job covering minor updates?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one

groups:
golang:
patterns:
Expand Down
92 changes: 81 additions & 11 deletions .github/workflows/autoupdate-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
schedule:
- cron: 30 8 * * TUE
workflow_dispatch:

jobs:
update-sdk:
runs-on: ubuntu-latest
Expand All @@ -13,23 +12,94 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: update
run: |
go install github.com/icholy/gomajor@latest
make update-atlas-sdk
- run: go install github.com/icholy/gomajor@latest
- id: version
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@1e517a7f5663673148ceb7c09c1900e5af48e7a1
id: verify-changed-files
with:
files: |
./internal/**/*
- uses: peter-evans/create-pull-request@v6
go.mod
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the actual change to make it work for minor and patch versions

go.sum
- 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 }}
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"
- name: Create JIRA ticket
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 '{
"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}"'"
}
}
}')

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}"
- uses: peter-evans/create-pull-request@v6
id: pr
if: steps.verify-changed-files.outputs.files_changed == 'true' && steps.find.outputs.FOUND == 'false'
with:
title: "APIBot: Atlas GO SDK update"
commit-message: "build(deps): bump go.mongodb.org/atlas-sdk"
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 }}"
delete-branch: true
branch: atlas-sdk-update
base: master
branch: ${{ steps.create.outputs.jira-ticket-id }}
labels: |
dependencies
go
atlas-sdk
body: |
Automatic update for MongoDB Atlas Go Client SDK
## Proposed changes
Update MongoDB Atlas Go Client SDK to ${{ steps.version.outputs.VERSION }}
_Jira ticket:_ ${{ steps.create.outputs.jira-ticket-id }}