|
| 1 | +name: Update Compliance Report |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + tag: |
| 9 | + description: 'atlascli tag version (e.g. 1.42.2)' |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + |
| 13 | +jobs: |
| 14 | + update-compliance-report: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: GitHubSecurityLab/actions-permissions/monitor@v1 |
| 18 | + with: |
| 19 | + config: ${{ vars.PERMISSIONS_CONFIG }} |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + - name: Extract AUTHOR and VERSION |
| 23 | + id: extract |
| 24 | + run: | |
| 25 | + if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then |
| 26 | + # Expect input like 'atlascli/v1.42.2' or '1.42.2' |
| 27 | + TAG="${{ github.event.inputs.tag }}" |
| 28 | + VERSION="${TAG#atlascli/v}" |
| 29 | + AUTHOR="${{ github.actor }}" |
| 30 | + else |
| 31 | + # GITHUB_REF is refs/tags/atlascli/v1.42.2 |
| 32 | + VERSION="${GITHUB_REF#refs/tags/atlascli/v}" |
| 33 | + AUTHOR="${{ github.event.release.author.login }}" |
| 34 | + fi |
| 35 | + echo "author=$AUTHOR" >> "$GITHUB_OUTPUT" |
| 36 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 37 | + - name: Run gen-ssdlc-report.sh |
| 38 | + env: |
| 39 | + AUTHOR: ${{ steps.extract.outputs.author }} |
| 40 | + VERSION: ${{ steps.extract.outputs.version }} |
| 41 | + run: ./build/package/gen-ssdlc-report.sh |
| 42 | + - name: set Apix Bot token |
| 43 | + id: app-token |
| 44 | + uses: mongodb/apix-action/token@3024080388613583e3bd119bfb1ab4b4dbf43c42 |
| 45 | + with: |
| 46 | + app-id: ${{ secrets.APIXBOT_APP_ID }} |
| 47 | + private-key: ${{ secrets.APIXBOT_APP_PEM }} |
| 48 | + - name: Find JIRA ticket |
| 49 | + id: find |
| 50 | + uses: mongodb/apix-action/find-jira@3024080388613583e3bd119bfb1ab4b4dbf43c42 |
| 51 | + with: |
| 52 | + token: ${{ secrets.JIRA_API_TOKEN }} |
| 53 | + jql: project = CLOUDP AND status NOT IN (Closed, Resolved) AND summary ~ "Update Compliance Report" |
| 54 | + - name: Set JIRA ticket (find) |
| 55 | + if: steps.find.outputs.found == 'true' |
| 56 | + run: | |
| 57 | + echo "JIRA_KEY=${{steps.find.outputs.issue-key}}" >> "$GITHUB_ENV" |
| 58 | + - name: Create JIRA ticket |
| 59 | + uses: mongodb/apix-action/create-jira@3024080388613583e3bd119bfb1ab4b4dbf43c42 |
| 60 | + id: create |
| 61 | + if: steps.find.outputs.found == 'false' |
| 62 | + with: |
| 63 | + token: ${{ secrets.JIRA_API_TOKEN }} |
| 64 | + project-key: CLOUDP |
| 65 | + summary: "[AtlasCLI] Update Compliance Report" |
| 66 | + issuetype: Story |
| 67 | + description: Update Compliance Report |
| 68 | + components: AtlasCLI |
| 69 | + assignee: ${{ secrets.ASSIGNEE_JIRA_TICKET }} |
| 70 | + extra-data: | |
| 71 | + { |
| 72 | + "fields": { |
| 73 | + "fixVersions": [ |
| 74 | + { |
| 75 | + "id": "41805" |
| 76 | + } |
| 77 | + ], |
| 78 | + "customfield_12751": [ |
| 79 | + { |
| 80 | + "id": "22223" |
| 81 | + } |
| 82 | + ], |
| 83 | + "customfield_10257": { |
| 84 | + "id": "11861" |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | + - name: Set JIRA ticket (create) |
| 89 | + if: steps.find.outputs.found == 'false' |
| 90 | + run: | |
| 91 | + echo "JIRA_KEY=${{steps.create.outputs.issue-key}}" >> "$GITHUB_ENV" |
| 92 | + - uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e |
| 93 | + id: pr |
| 94 | + with: |
| 95 | + token: ${{ steps.app-token.outputs.token }} |
| 96 | + committer: "${{ steps.app-token.outputs.user-name }} <${{ steps.app-token.outputs.user-email }}>" |
| 97 | + author: "${{ steps.app-token.outputs.user-name }} <${{ steps.app-token.outputs.user-email }}>" |
| 98 | + title: "${{ env.JIRA_KEY }}: Update compliance report for v${{ steps.extract.outputs.version }}" |
| 99 | + commit-message: "${{ env.JIRA_KEY }}: Update compliance report for v${{ steps.extract.outputs.version }}" |
| 100 | + delete-branch: true |
| 101 | + base: master |
| 102 | + branch: ${{ env.JIRA_KEY }} |
| 103 | + labels: | |
| 104 | + compliance |
| 105 | + auto |
| 106 | + auto_close_jira |
| 107 | + body: | |
| 108 | + ## Proposed changes |
| 109 | + Update compliance report for v${{ steps.extract.outputs.version }} |
| 110 | + _Jira ticket:_ ${{ env.JIRA_KEY }} |
| 111 | +
|
| 112 | + Note: Jira ticket will be closed automatically when this PR is merged. |
| 113 | +
|
| 114 | + - name: Set auto merge |
| 115 | + env: |
| 116 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 117 | + run: | |
| 118 | + gh pr merge "${{ steps.pr.outputs.pull-request-url }}" --auto --squash |
0 commit comments