-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
tools: notify on Slack when invalid commit lands #47178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
name: Notify on Push | ||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
notifyOnForcePush: | ||
name: Notify on Force Push on `main` | ||
if: github.repository == 'nodejs/node' && github.event.forced | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Slack Notification | ||
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 | ||
env: | ||
SLACK_COLOR: '#DE512A' | ||
SLACK_ICON: https://github.com/nodejs.png?size=48 | ||
SLACK_TITLE: ${{ github.actor }} force-pushed to ${{ github.ref }} | ||
SLACK_MESSAGE: | | ||
A commit was force-pushed to <https://github.com/${{ github.repository }}/tree/${{ github.repository.default_branch }}|${{ github.repository }}@${{ github.repository.default_branch }}> by <https://github.com/${{ github.actor }}|${{ github.actor }}> | ||
|
||
Before: <https://github.com/${{ github.repository }}/commit/${{ github.event.before }}|${{ github.event.before }}> | ||
After: <https://github.com/${{ github.repository }}/commit/${{ github.event.after }}|${{ github.event.after }}> | ||
SLACK_USERNAME: nodejs-bot | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
|
||
notifyOnMissingMetadata: | ||
name: Notify on Push on `main` that lacks metadata | ||
if: github.repository == 'nodejs/node' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check commit message | ||
run: npx -q core-validate-commit ${{ github.event.commits[0].id }} || echo "INVALID_COMMIT_MESSAGE=1" >> $GITHUB_ENV | ||
- name: Retrieve PR number if possible | ||
if: ${{ env.INVALID_COMMIT_MESSAGE }} | ||
run: | | ||
node <<<'EOF' | ||
const invalidCommitMessageMatch = /\s\(\#\d+\)$/.exec(process.env.COMMIT_MESSAGE); | ||
if (match == null) process.exit(1) | ||
console.log(`PR_ID=${match[0]}`) | ||
EOF >> $GITHUB_ENV || true | ||
env: | ||
COMMIT_MESSAGE: ${{ github.event.commits[0].message }} | ||
- name: Comment on the Pull Request | ||
if: ${{ env.PR_ID }} | ||
run: gh pr comment ${{ env.PR_ID }} --repo "${{ github.repository }}" --body "$BODY" | ||
env: | ||
BODY: | | ||
A commit referencing this Pull Request was pushed to `main` by @${{ github.actor }} without the expected commit metadata added to its message. | ||
- name: Slack Notification | ||
if: ${{ env.INVALID_COMMIT_MESSAGE }} | ||
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7 | ||
env: | ||
SLACK_COLOR: '#DE512A' | ||
SLACK_ICON: https://github.com/nodejs.png?size=48 | ||
SLACK_TITLE: Invalid commit was pushed to ${{ github.repository.default_branch }} | ||
SLACK_MESSAGE: | | ||
A commit lacking the expected metadata was pushed to <https://github.com/${{ github.repository }}/tree/${{ github.repository.default_branch }}|${{ github.repository }}@${{ github.repository.default_branch }}> by <https://github.com/${{ github.actor }}|${{ github.actor }}>. | ||
|
||
Before: <https://github.com/${{ github.repository }}/commit/${{ github.event.before }}|${{ github.event.before }}> | ||
After: <https://github.com/${{ github.repository }}/commit/${{ github.event.after }}|${{ github.event.after }}> | ||
SLACK_USERNAME: nodejs-bot | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.