Skip to content

Update SDK

Update SDK #67

name: Update SDK
on:
schedule:
- cron: 30 8 * * TUE
workflow_dispatch:
jobs:
update-sdk:
runs-on: ubuntu-latest
steps:
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
with:
config: ${{ vars.PERMISSIONS_CONFIG }}
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- 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@79f398ac63ab46f7f820470c821d830e5c340ef9
id: verify-changed-files
with:
files: |
./internal/**/*
go.mod
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: "${{ 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
base: master
branch: ${{ steps.create.outputs.jira-ticket-id }}
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 }}