Skip to content

Commit c4c0778

Browse files
committed
Add PR notification to #oss-alerts
1 parent 85ac928 commit c4c0778

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

.github/workflows/notify-pr.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: PR Notification
2+
on:
3+
pull_request_target:
4+
types: [opened]
5+
jobs:
6+
notify:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Notify Slack
10+
if: github.actor != 'github-actions[bot]'
11+
env:
12+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
13+
PR_TITLE: ${{ github.event.pull_request.title }}
14+
PR_URL: ${{ github.event.pull_request.html_url }}
15+
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
16+
PR_NUM: ${{ github.event.pull_request.number }}
17+
REPO_NAME: ${{ github.event.repository.name }}
18+
run: |
19+
if [ -z "$SLACK_WEBHOOK" ]; then echo "SLACK_WEBHOOK not set, skipping"; exit 0; fi
20+
PAYLOAD=$(jq -n \
21+
--arg text "New PR #${PR_NUM} on ${REPO_NAME} by *${PR_AUTHOR}*: <${PR_URL}|${PR_TITLE}>" \
22+
'{text: $text}')
23+
curl -sf -X POST "$SLACK_WEBHOOK" \
24+
-H "Content-Type: application/json" \
25+
-d "$PAYLOAD"

0 commit comments

Comments
 (0)