build: workflow concurrency for PR title check #525
Workflow file for this run
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: PR Title Check | |
| on: | |
| pull_request_target: | |
| types: [opened, edited, synchronize, reopened] | |
| # Most recent PR change superseeds previous changes. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| # Default to the minimum read-only token for all jobs. | |
| permissions: | |
| contents: read | |
| jobs: | |
| commitlint: | |
| name: PR title / description conforms to semantic-release | |
| runs-on: ubuntu-latest | |
| outputs: | |
| outcome: ${{ steps.commitlint.outcome }} | |
| steps: | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: "24" | |
| - run: npm install @commitlint/config-conventional | |
| - run: > | |
| echo 'module.exports = { | |
| // Workaround for https://github.com/dependabot/dependabot-core/issues/5923 | |
| "ignores": [ | |
| (message) => /^Bumps \[.+]\(.+\) from .+ to .+\.$/m.test(message), | |
| (message) => /^Updates the requirements on .+ to permit the latest version\.$/m.test(message) | |
| ], | |
| "rules": { | |
| "body-max-line-length": [0, "always", Infinity], | |
| "footer-max-line-length": [0, "always", Infinity], | |
| "body-leading-blank": [0, "always"] | |
| } | |
| }' > .commitlintrc.js | |
| - id: commitlint | |
| continue-on-error: true | |
| run: npx commitlint --extends @commitlint/config-conventional --verbose <<< $COMMIT_MSG | |
| env: | |
| COMMIT_MSG: > | |
| ${{ github.event.pull_request.title }} | |
| ${{ github.event.pull_request.body }} | |
| comment: | |
| name: Post / remove PR comment | |
| runs-on: ubuntu-latest | |
| needs: commitlint | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| // Hidden marker used to find this job's comment regardless of wording. | |
| const marker = "<!-- pr-title-check -->"; | |
| const message = `${marker} | |
| **ACTION NEEDED** | |
| Substrait follows the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) for release automation. | |
| The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification.`; | |
| const passed = "${{ needs.commitlint.outputs.outcome }}" === "success"; | |
| // Find an existing comment from this job, if any. | |
| const comments = await github.paginate(github.rest.issues.listComments, { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const existing = comments.find((c) => c.body.includes(marker)); | |
| if (passed) { | |
| // Clean up the comment now that the check passes. | |
| if (existing) { | |
| await github.rest.issues.deleteComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| }); | |
| } | |
| return; | |
| } | |
| // Check failed: post the comment if it isn't already there, then fail the job. | |
| if (!existing) { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: message, | |
| }); | |
| } | |
| core.setFailed( | |
| "PR title and description do not follow the Conventional Commits specification." | |
| ); |