Update API Commands #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update API Commands | |
on: | |
schedule: | |
- cron: 30 8 * * TUE | |
workflow_dispatch: | |
jobs: | |
update-api: | |
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: make update-openapi-spec | |
- name: Verify Changed files | |
run: | | |
FILES_CHANGED=false | |
if git diff --name-only | grep -qE '^tools/internal/specs/spec\.yaml'; then | |
FILES_CHANGED=true | |
fi | |
echo "FILES_CHANGED=${FILES_CHANGED}" >> "$GITHUB_ENV" | |
- run: make gen-api-commands | |
if: env.FILES_CHANGED == 'true' | |
- run: make gen-docs | |
if: env.FILES_CHANGED == 'true' | |
- name: Find JIRA ticket | |
id: find | |
if: env.FILES_CHANGED == 'true' | |
uses: mongodb/apix-action/find-jira@3024080388613583e3bd119bfb1ab4b4dbf43c42 | |
with: | |
token: ${{ secrets.JIRA_API_TOKEN }} | |
jql: project = CLOUDP AND status NOT IN (Closed, Resolved) AND summary ~ "Update Autogenerated Commands" | |
- name: Set JIRA ticket (find) | |
if: (env.FILES_CHANGED == 'true') && (steps.find.outputs.found == 'true') | |
run: | | |
echo "JIRA_KEY=${{steps.find.outputs.issue-key}}" >> "$GITHUB_ENV" | |
- name: Create JIRA ticket | |
uses: mongodb/apix-action/create-jira@3024080388613583e3bd119bfb1ab4b4dbf43c42 | |
id: create | |
if: (env.FILES_CHANGED == 'true') && (steps.find.outputs.found == 'false') | |
with: | |
token: ${{ secrets.JIRA_API_TOKEN }} | |
project-key: CLOUDP | |
summary: "[AtlasCLI] Update Autogenerated Commands" | |
issuetype: Story | |
description: Update Autogenerated Commands | |
components: AtlasCLI | |
assignee: ${{ secrets.ASSIGNEE_JIRA_TICKET }} | |
extra-data: | | |
{ | |
"fields": { | |
"fixVersions": [ | |
{ | |
"id": "41805" | |
} | |
], | |
"customfield_12751": [ | |
{ | |
"id": "22223" | |
} | |
], | |
"customfield_10257": { | |
"id": "11861" | |
} | |
} | |
} | |
- name: Set JIRA ticket (create) | |
if: (env.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: env.FILES_CHANGED == 'true' | |
id: app-token | |
uses: mongodb/apix-action/token@3024080388613583e3bd119bfb1ab4b4dbf43c42 | |
with: | |
app-id: ${{ secrets.APIXBOT_APP_ID }} | |
private-key: ${{ secrets.APIXBOT_APP_PEM }} | |
- uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e | |
id: pr | |
if: env.FILES_CHANGED == 'true' | |
with: | |
token: ${{ steps.app-token.outputs.token }} | |
committer: "${{ steps.app-token.outputs.user-name }} <${{ steps.app-token.outputs.user-email }}>" | |
author: "${{ steps.app-token.outputs.user-name }} <${{ steps.app-token.outputs.user-email }}>" | |
title: "${{ env.JIRA_KEY }}: Update Autogenerated Commands" | |
commit-message: "${{ env.JIRA_KEY }}: Update Autogenerated Commands" | |
delete-branch: true | |
base: master | |
branch: ${{ env.JIRA_KEY }} | |
labels: | | |
dependencies | |
go | |
auto_close_jira | |
body: | | |
## Proposed changes | |
Update Autogenerated Commands | |
_Jira ticket:_ ${{ env.JIRA_KEY }} | |
Note: Jira ticket will be closed automatically when this PR is merged. | |
- name: Set auto merge | |
env: | |
GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
run: | | |
gh pr merge "${{ steps.pr.outputs.pull-request-url }}" --auto --squash |