Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 816e215

Browse filesBrowse files
aduh95danielleadams
authored andcommitted
tools: fix Slack notification action
PR-URL: #47237 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
1 parent 7fb1980 commit 816e215
Copy full SHA for 816e215

File tree

Expand file treeCollapse file tree

1 file changed

+16
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-12
lines changed
Open diff view settings
Collapse file

‎.github/workflows/notify-on-push.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/notify-on-push.yml
+16-12Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,29 @@ jobs:
3131
name: Notify on Push on `main` that lacks metadata
3232
if: github.repository == 'nodejs/node'
3333
runs-on: ubuntu-latest
34+
permissions:
35+
pull-requests: write
3436
steps:
37+
- uses: actions/checkout@v3
38+
with:
39+
persist-credentials: false
3540
- 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
3742
- name: Retrieve PR number if possible
38-
if: ${{ env.INVALID_COMMIT_MESSAGE }}
43+
if: env.INVALID_COMMIT_MESSAGE
3944
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
4750
- name: Comment on the Pull Request
4851
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."
5055
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 }}
5357
- name: Slack Notification
5458
if: ${{ env.INVALID_COMMIT_MESSAGE }}
5559
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.