Skip to content

Update devdocs-notify.yml #17

Update devdocs-notify.yml

Update devdocs-notify.yml #17

name: DevDocs PR or Issue Creation Notifier
on:
issues:
types: [opened]
pull_request_target:
types: [opened]
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Check for new PR or issues
env:
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_USER: ${{ github.event.issue.user.login }}
ISSUE_URL: ${{ github.event.issue.html_url }}
REPO_NAME: ${{ github.repository }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
# Build message text using jq to safely handle user input
MESSAGE_TEXT=$(jq -n \
--arg repo "$REPO_NAME" \
--arg title "$ISSUE_TITLE" \
--arg user "$ISSUE_USER" \
--arg url "$ISSUE_URL" \
'*📢 @DevDocs a PR was opened or issue created in \($repo) 📢*')
# Build Slack payload
SLACK_PAYLOAD=$(jq -n \
--arg text "$MESSAGE_TEXT" \
'{
"channel": "#docs-devdocs-notifications",
"username": "Issue Notifier",
"icon_emoji": ":mega:",
"text": $text
}')
# Send to Slack
curl -X POST \
-H 'Content-type: application/json' \
--data "$SLACK_PAYLOAD" \
"$SLACK_WEBHOOK"