| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,25 +31,29 @@ jobs: | |||
| 31 | 31 | name: Notify on Push on `main` that lacks metadata | |
| 32 | 32 | if: github.repository == 'nodejs/node' | |
| 33 | 33 | runs-on: ubuntu-latest | |
| 34 | + permissions: | ||
| 35 | + pull-requests: write | ||
| 34 | 36 | steps: | |
| 37 | + - uses: actions/checkout@v3 | ||
| 38 | + with: | ||
| 39 | + persist-credentials: false | ||
| 35 | 40 | - name: Check commit message | |
| 36 | - run: npx -q core-validate-commit ${{ github.event.commits[0].id }} || echo "INVALID_COMMIT_MESSAGE=1" >> $GITHUB_ENV | ||
| 41 | + run: npx -q core-validate-commit ${{ github.event.after }} || echo "INVALID_COMMIT_MESSAGE=1" >> $GITHUB_ENV | ||
| 37 | 42 | - name: Retrieve PR number if possible | |
| 38 | - if: ${{ env.INVALID_COMMIT_MESSAGE }} | ||
| 43 | + if: env.INVALID_COMMIT_MESSAGE | ||
| 39 | 44 | run: | | |
| 40 | - node <<<'EOF' | ||
| 41 | - const invalidCommitMessageMatch = /\s\(\#\d+\)$/.exec(process.env.COMMIT_MESSAGE); | ||
| 42 | - if (match == null) process.exit(1) | ||
| 43 | - console.log(`PR_ID=${match[0]}`) | ||
| 44 | - EOF >> $GITHUB_ENV || true | ||
| 45 | - env: | ||
| 46 | - COMMIT_MESSAGE: ${{ github.event.commits[0].message }} | ||
| 45 | + COMMIT_TITLE=$(git --no-pager log --oneline -1 --no-color) node <<'EOF' >> $GITHUB_ENV || true | ||
| 46 | + const invalidCommitMessageMatch = /\s\(\#(\d+)\)$/.exec(process.env.COMMIT_TITLE); | ||
| 47 | + if (invalidCommitMessageMatch == null) process.exit(1) | ||
| 48 | + console.log(`PR_ID=${invalidCommitMessageMatch[1]}`) | ||
| 49 | + EOF | ||
| 47 | 50 | - name: Comment on the Pull Request | |
| 48 | 51 | if: ${{ env.PR_ID }} | |
| 49 | - run: gh pr comment ${{ env.PR_ID }} --repo "${{ github.repository }}" --body "$BODY" | ||
| 52 | + run: | | ||
| 53 | + gh pr comment ${{ env.PR_ID }} --repo "${{ github.repository }}" \ | ||
| 54 | + --body "A commit referencing this Pull Request was pushed to `main` by @${{ github.actor }} without the expected commit metadata added to its message." | ||
| 50 | 55 | env: | |
| 51 | - BODY: | | ||
| 52 | - A commit referencing this Pull Request was pushed to `main` by @${{ github.actor }} without the expected commit metadata added to its message. | ||
| 56 | + GH_TOKEN: ${{ github.token }} | ||
| 53 | 57 | - name: Slack Notification | |
| 54 | 58 | if: ${{ env.INVALID_COMMIT_MESSAGE }} | |
| 55 | 59 | uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments