merge commit for archive created by Sapling #1542
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: π Check Conventional Commit | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| on: | |
| pull_request: | |
| push: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| commitlint: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| is_success: ${{ steps.commitlint.outputs.is_success }} | |
| commitlint_log: ${{ steps.commitlint.outputs.commitlint_log }} | |
| if: startsWith(github.ref_name, 'sapling-pr-archive-') == false | |
| steps: | |
| - name: π₯ Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: π£ Install bun | |
| uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 | |
| with: | |
| bun-version: canary | |
| - name: π¦ Install commitlint | |
| run: bun add -d @commitlint/cli @commitlint/config-conventional | |
| - name: π Create commitlint config | |
| run: | | |
| echo 'export default { extends: ["@commitlint/config-conventional"], | |
| ignores: [(message: string) => message.includes("Signed-off-by: dependabot[bot]")] }' > commitlint.config.ts | |
| - name: π Validate current commit (last commit) with commitlint | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| run: bun commitlint --last --verbose | |
| - name: π Validate PR commits with commitlint | |
| if: github.event_name == 'pull_request' | |
| id: commitlint | |
| env: | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: | | |
| bun commitlint --from $BASE_SHA --to $HEAD_SHA --verbose \ | |
| &> >(tee -p commitlint.log) || STATUS=$? | |
| if [ $STATUS -ne 0 ]; then | |
| echo "is_success=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_success=true" >> $GITHUB_OUTPUT | |
| fi | |
| UUID=$(uuidgen) | |
| { | |
| echo "commitlint_log<<EOF_$UUID" | |
| cat commitlint.log | |
| echo "EOF_$UUID" | |
| } >> $GITHUB_OUTPUT | |
| - name: π Fail if test failed | |
| if: steps.commitlint.outputs.is_success == 'false' | |
| run: exit 1 | |
| upload: | |
| runs-on: ubuntu-latest | |
| needs: commitlint | |
| if: (success() || failure()) && github.event_name == 'pull_request' | |
| steps: | |
| - name: β Create test failed comment | |
| if: needs.commitlint.outputs.is_success == 'false' | |
| env: | |
| ACTOR: ${{ github.actor }} | |
| COMMITLINT_LOG: ${{ needs.commitlint.outputs.commitlint_log }} | |
| REPO: ${{ github.repository }} | |
| RUN_ID: ${{ github.run_id }} | |
| SHA: ${{ github.event.pull_request.head.sha }} | |
| run: | | |
| UUID=$(uuidgen) | |
| cat <<EOF_$UUID > comment.txt | |
| # β Commitlint Failed | |
| @$ACTOR, your commit $SHA failed the commitlint check. | |
| <details> | |
| <summary><strong>Commitlint Log</strong></summary> | |
| \`\`\`shell | |
| $COMMITLINT_LOG | |
| \`\`\` | |
| </details> | |
| Please update the commit message to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). | |
| π[View in Actions](https://github.com/$REPO/actions/runs/$RUN_ID) | |
| <!-- generated-comment [Commitlint](https://github.com/$REPO/.github/workflows/commitlint.yml) --> | |
| EOF_$UUID | |
| - name: β Create test success comment | |
| if: needs.commitlint.outputs.is_success == 'true' | |
| env: | |
| REPO: ${{ github.repository }} | |
| run: | | |
| UUID=$(uuidgen) | |
| cat <<EOF_$UUID > comment.txt | |
| # β Commitlint Passed | |
| Thank you for updating the commit message to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). | |
| <!-- generated-comment [Commitlint](https://github.com/$REPO/.github/workflows/commitlint.yml) --> | |
| EOF_$UUID | |
| - name: π’ Create pull request number and title | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| echo "$PR_NUMBER" > pr_number.txt | |
| echo "# β Commitlint Failed" > title.txt | |
| - name: π Upload test comment | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: comment | |
| path: comment.txt | |
| - name: π Upload pull request number | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: pr_number | |
| path: pr_number.txt | |
| - name: π Upload title | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: title | |
| path: title.txt |