2023-03-23 10:38:17 +01:00
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
2024-11-03 20:05:54 +01:00
uses : rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # 2.3.2
2023-03-23 10:38:17 +01:00
env :
SLACK_COLOR : '#DE512A'
SLACK_ICON : https://github.com/nodejs.png?size=48
SLACK_TITLE : ${{ github.actor }} force-pushed to ${{ github.ref }}
SLACK_MESSAGE : |
2023-04-08 17:17:50 +02:00
<!here> A commit was force-pushed to <https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}|${{ github.repository }}@${{ github.ref_name }}> by <https://github.com/${{ github.actor }}|${{ github.actor }}>
2023-03-23 10:38:17 +01:00
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
2023-03-23 22:17:55 +01:00
permissions :
pull-requests : write
2023-03-23 10:38:17 +01:00
steps :
2024-11-03 20:03:33 +01:00
- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2023-03-23 22:17:55 +01:00
with :
persist-credentials : false
2023-03-23 10:38:17 +01:00
- name : Check commit message
2023-03-23 22:17:55 +01:00
run : npx -q core-validate-commit ${{ github.event.after }} || echo "INVALID_COMMIT_MESSAGE=1" >> $GITHUB_ENV
2023-03-23 10:38:17 +01:00
- name : Retrieve PR number if possible
2023-03-23 22:17:55 +01:00
if : env.INVALID_COMMIT_MESSAGE
2023-03-23 10:38:17 +01:00
run : |
2023-03-23 22:17:55 +01:00
COMMIT_TITLE=$(git --no-pager log --oneline -1 --no-color) node <<'EOF' >> $GITHUB_ENV || true
const invalidCommitMessageMatch = /\s\(\#(\d+)\)$/.exec(process.env.COMMIT_TITLE);
if (invalidCommitMessageMatch == null) process.exit(1)
console.log(`PR_ID=${invalidCommitMessageMatch[1]}`)
EOF
2023-03-23 10:38:17 +01:00
- name : Comment on the Pull Request
if : ${{ env.PR_ID }}
2023-03-23 22:17:55 +01:00
run : |
gh pr comment ${{ env.PR_ID }} --repo "${{ github.repository }}" \
2023-04-08 17:17:50 +02:00
--body "A commit referencing this Pull Request was pushed to `${{ github.ref_name }}` by @${{ github.actor }} with an invalid commit message."
2023-03-23 10:38:17 +01:00
env :
2023-03-23 22:17:55 +01:00
GH_TOKEN : ${{ github.token }}
2023-03-23 10:38:17 +01:00
- name : Slack Notification
if : ${{ env.INVALID_COMMIT_MESSAGE }}
2024-11-03 20:05:54 +01:00
uses : rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # 2.3.2
2023-03-23 10:38:17 +01:00
env :
SLACK_COLOR : '#DE512A'
SLACK_ICON : https://github.com/nodejs.png?size=48
2024-07-21 21:43:40 +02:00
SLACK_TITLE : Invalid commit was pushed to ${{ github.ref }}
2023-03-23 10:38:17 +01:00
SLACK_MESSAGE : |
2023-04-08 17:17:50 +02:00
<!here> A commit with an invalid message was pushed to <https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}|${{ github.repository }}@${{ github.ref_name }}> by <https://github.com/${{ github.actor }}|${{ github.actor }}>.
2023-03-23 10:38:17 +01:00
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 }}