Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/pr-slack-notification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: PR Slack Notification

on:
workflow_call:
secrets:
slack_webhook_url:
required: true

permissions: {}

jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Post to Slack
env:
SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook_url }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_URL: ${{ github.event.pull_request.html_url }}
REPOSITORY: ${{ github.repository }}
run: |
set -o pipefail

jq -n \
--arg author "$PR_AUTHOR" \
--arg number "$PR_NUMBER" \
--arg repository "$REPOSITORY" \
--arg title "$PR_TITLE" \
--arg url "$PR_URL" \
'{
text: "Pull request notification",
blocks: [
{type: "section", text: {type: "mrkdwn", text: ("*Pull request:* <" + $url + "|" + $repository + " #" + $number + ">")}},
{type: "section", text: {type: "plain_text", text: ($title + " — by @" + $author), emoji: true}}
]
}' |
curl --fail-with-body --silent --show-error \
--header 'Content-type: application/json' \
--data @- \
"$SLACK_WEBHOOK_URL"