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
2023-09-07 08:43:07 +02:00
uses : rtCamp/action-slack-notify@b24d75fe0e728a4bf9fc42ee217caa686d141ee8 # 2.2.1
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 :
2023-10-04 21:04:52 +02:00
- uses : actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
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 }}
2023-09-07 08:43:07 +02:00
uses : rtCamp/action-slack-notify@b24d75fe0e728a4bf9fc42ee217caa686d141ee8 # 2.2.1
2023-03-23 10:38:17 +01:00
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 : |
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 }}