Update API Commands #65
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@v6.0.2 | |
| - uses: actions/setup-go@v6 | |
| 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@6c3fde402c21942fa46cde003f190c2b23c59530 | |
| 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@6c3fde402c21942fa46cde003f190c2b23c59530 | |
| 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": [ | |
| { | |
| "name": "next-atlascli-release" | |
| } | |
| ], | |
| "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@6c3fde402c21942fa46cde003f190c2b23c59530 | |
| with: | |
| app-id: ${{ secrets.APIXBOT_APP_ID }} | |
| private-key: ${{ secrets.APIXBOT_APP_PEM }} | |
| - uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 | |
| 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 | |
| if: env.FILES_CHANGED == 'true' | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | | |
| gh pr merge "${{ steps.pr.outputs.pull-request-url }}" --auto --squash | |
| - name: Find JIRA ticket (on failure) | |
| id: find-failure | |
| if: failure() && env.FILES_CHANGED != 'true' | |
| uses: mongodb/apix-action/find-jira@6c3fde402c21942fa46cde003f190c2b23c59530 | |
| with: | |
| token: ${{ secrets.JIRA_API_TOKEN }} | |
| jql: project = CLOUDP AND status NOT IN (Closed, Resolved) AND summary ~ "Update Autogenerated Commands - Workflow Failed" | |
| - name: Create JIRA ticket (on failure) | |
| uses: mongodb/apix-action/create-jira@6c3fde402c21942fa46cde003f190c2b23c59530 | |
| id: create-failure | |
| if: failure() && (env.FILES_CHANGED != 'true') && (steps.find-failure.outputs.found == 'false') | |
| with: | |
| token: ${{ secrets.JIRA_API_TOKEN }} | |
| project-key: CLOUDP | |
| summary: "[AtlasCLI] Update Autogenerated Commands - Workflow Failed" | |
| issuetype: Bug | |
| description: | | |
| The automated workflow to update autogenerated commands has failed. | |
| Please investigate the workflow run and fix any issues. | |
| Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| components: AtlasCLI | |
| assignee: ${{ secrets.ASSIGNEE_JIRA_TICKET }} | |
| extra-data: | | |
| { | |
| "fields": { | |
| "fixVersions": [ | |
| { | |
| "name": "next-atlascli-release" | |
| } | |
| ], | |
| "customfield_12751": [ | |
| { | |
| "id": "22223" | |
| } | |
| ], | |
| "customfield_10257": { | |
| "id": "11861" | |
| } | |
| } | |
| } |