Update devdocs-notify.yml #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: DevDocs PR or Issue Creation Notifier | |
| on: | |
| pull_request_target: | |
| types: [opened] | |
| jobs: | |
| notify: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Send Slack Notification | |
| env: | |
| # Use the correct 'pull_request' context | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| PR_USER: ${{ github.event.pull_request.user.login }} | |
| PR_URL: ${{ github.event.pull_request.html_url }} | |
| REPO_NAME: ${{ github.repository }} | |
| SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
| run: | | |
| # Build the message and payload in one step | |
| SLACK_PAYLOAD=$(jq -n \ | |
| --arg repo "$REPO_NAME" \ | |
| --arg title "$PR_TITLE" \ | |
| --arg user "$PR_USER" \ | |
| --arg url "$PR_URL" \ | |
| '{ | |
| "channel": "#docs-devdocs-notifications", | |
| "username": "Issue Notifier", | |
| "icon_emoji": ":mega:", | |
| "text": "*:eyes: @DevDocs a PR was opened in * \($repo)\n*Title:* \($title)\n*By:* \($user)\n*URL:* \($url)" | |
| }') | |
| # Send to Slack | |
| curl -X POST \ | |
| -H 'Content-type: application/json' \ | |
| --data "$SLACK_PAYLOAD" \ | |
| "$SLACK_WEBHOOK" |