Skip to content

Commit 766dd6a

Browse files
Create devdocs-notify.yml
Initial commit to send Slack notifications to DevDocs when a new PR is opened or when an Issue is created.
1 parent 1995ca4 commit 766dd6a

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: DevDocs PR or Issue Creation Notifier
2+
on:
3+
issues:
4+
types: [opened]
5+
pull_request_target:
6+
types: [opened]
7+
8+
jobs:
9+
notify:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check for new PR or issues
13+
env:
14+
REPO_NAME: ${{ github.repository }}
15+
# Make sure this secret name matches what is in your Repo Settings
16+
PR_TITLE: ${{ github.event.pull_request.title || github.event.issue.title }}
17+
PR_USER: ${{ github.event.pull_request.user.login || github.event.comment.user.login }}
18+
PR_URL: ${{ github.event.pull_request.html_url || github.event.comment.html_url }}
19+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
20+
run: |
21+
# Build Slack payload safely using jq
22+
SLACK_PAYLOAD=$(jq -n \
23+
--arg repo "$REPO_NAME" \
24+
--arg title "$PR_TITLE" \
25+
--arg user "$PR_USER" \
26+
--arg url "$PR_URL" \
27+
'{
28+
"channel": "#docs-devdocs-notifications",
29+
"username": "Issue Notifier",
30+
"icon_emoji": ":mega:",
31+
"text": "*📢 @DevDocs a PR was opened or issue created in * \($repo)\n*Title:* \($title)\n*By:* \($user)\n*URL:* \($url)"
32+
}')
33+
34+
# Send to Slack
35+
curl -X POST \
36+
-H 'Content-type: application/json' \
37+
--data "$SLACK_PAYLOAD" \
38+
"$SLACK_WEBHOOK"

0 commit comments

Comments
 (0)