| Eric Ball | 8f40444 | 2026-01-05 21:31:56 -0800 | [diff] [blame] | 1 | --- |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # SPDX-FileCopyrightText: 2026 The Linux Foundation |
| 4 | |
| 5 | name: Lint GitHub Actions workflows |
| 6 | |
| 7 | # yamllint disable-line rule:truthy |
| 8 | on: |
| 9 | workflow_dispatch: |
| 10 | inputs: |
| 11 | # Gerrit-to-Github defaults |
| 12 | GERRIT_BRANCH: |
| 13 | description: "Branch that change is against" |
| 14 | required: true |
| 15 | type: string |
| 16 | GERRIT_CHANGE_ID: |
| 17 | description: "The ID for the change" |
| 18 | required: true |
| 19 | type: string |
| 20 | GERRIT_CHANGE_NUMBER: |
| 21 | description: "The Gerrit number" |
| 22 | required: true |
| 23 | type: string |
| 24 | GERRIT_CHANGE_URL: |
| 25 | description: "URL to the change" |
| 26 | required: true |
| 27 | type: string |
| 28 | GERRIT_EVENT_TYPE: |
| 29 | description: "Type of Gerrit event" |
| 30 | required: true |
| 31 | type: string |
| 32 | GERRIT_PATCHSET_NUMBER: |
| 33 | description: "The patch number for the change" |
| 34 | required: true |
| 35 | type: string |
| 36 | GERRIT_PATCHSET_REVISION: |
| 37 | description: "The revision sha" |
| 38 | required: true |
| 39 | type: string |
| 40 | GERRIT_PROJECT: |
| 41 | description: "Project in Gerrit" |
| 42 | required: true |
| 43 | type: string |
| 44 | GERRIT_REFSPEC: |
| 45 | description: "Gerrit refspec of change" |
| 46 | required: true |
| 47 | type: string |
| Eric Ball | 50d6f8e | 2026-01-30 15:47:38 -0800 | [diff] [blame] | 48 | # Needed for voting |
| 49 | comment-only: |
| 50 | description: "Make this workflow advisory only, default false" |
| 51 | required: false |
| 52 | type: string |
| 53 | default: "false" |
| Eric Ball | 8f40444 | 2026-01-05 21:31:56 -0800 | [diff] [blame] | 54 | |
| 55 | concurrency: |
| 56 | # yamllint disable-line rule:line-length |
| 57 | group: verify-workflows-${{ github.workflow }}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }} |
| 58 | cancel-in-progress: true |
| 59 | |
| 60 | jobs: |
| Eric Ball | 50d6f8e | 2026-01-30 15:47:38 -0800 | [diff] [blame] | 61 | prepare: |
| 62 | runs-on: ubuntu-latest |
| 63 | steps: |
| 64 | - name: Clear votes |
| 65 | # yamllint disable-line rule:line-length |
| 66 | uses: lfreleng-actions/gerrit-review-action@537251ec667665b386f70b330b05446e3fc29087 # v0.9 |
| 67 | with: |
| 68 | host: ${{ vars.GERRIT_SERVER }} |
| 69 | username: ${{ vars.GERRIT_SSH_USER }} |
| 70 | key: ${{ secrets.GERRIT_SSH_PRIVKEY }} |
| 71 | known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }} |
| 72 | gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }} |
| 73 | gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }} |
| 74 | vote-type: clear |
| 75 | comment-only: ${{ inputs.comment-only }} |
| 76 | - name: Allow replication |
| 77 | run: sleep 10s |
| 78 | |
| Eric Ball | 8f40444 | 2026-01-05 21:31:56 -0800 | [diff] [blame] | 79 | actionlint: |
| Eric Ball | 50d6f8e | 2026-01-30 15:47:38 -0800 | [diff] [blame] | 80 | needs: prepare |
| Eric Ball | 8f40444 | 2026-01-05 21:31:56 -0800 | [diff] [blame] | 81 | runs-on: ubuntu-latest |
| 82 | steps: |
| 83 | # yamllint disable-line rule:line-length |
| 84 | - uses: lfreleng-actions/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9 |
| 85 | with: |
| 86 | gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }} |
| 87 | gerrit-project: ${{ inputs.GERRIT_PROJECT }} |
| 88 | gerrit-url: ${{ vars.GERRIT_URL }} |
| 89 | delay: "0s" |
| 90 | - name: Download actionlint |
| 91 | id: get_actionlint |
| 92 | # yamllint disable-line rule:line-length |
| 93 | run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) |
| 94 | shell: bash |
| 95 | - name: Check workflow files |
| 96 | run: ${{ steps.get_actionlint.outputs.executable }} -color |
| 97 | shell: bash |
| Eric Ball | 50d6f8e | 2026-01-30 15:47:38 -0800 | [diff] [blame] | 98 | |
| 99 | vote: |
| 100 | if: ${{ always() }} |
| 101 | needs: [prepare, actionlint] |
| 102 | runs-on: ubuntu-latest |
| 103 | steps: |
| 104 | - name: Get conclusion |
| 105 | # yamllint disable-line rule:line-length |
| 106 | uses: im-open/workflow-conclusion@e4f7c4980600fbe0818173e30931d3550801b992 # v2.2.3 |
| 107 | - name: Set vote |
| 108 | # yamllint disable-line rule:line-length |
| 109 | uses: lfreleng-actions/gerrit-review-action@537251ec667665b386f70b330b05446e3fc29087 # v0.9 |
| 110 | with: |
| 111 | host: ${{ vars.GERRIT_SERVER }} |
| 112 | username: ${{ vars.GERRIT_SSH_USER }} |
| 113 | key: ${{ secrets.GERRIT_SSH_PRIVKEY }} |
| 114 | known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }} |
| 115 | gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }} |
| 116 | gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }} |
| 117 | vote-type: ${{ env.WORKFLOW_CONCLUSION }} |
| 118 | comment-only: ${{ inputs.comment-only }} |