Skip to content

Commit b5e4b6c

Browse files
Update devdocs-notify.yml
1 parent 502747a commit b5e4b6c

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

.github/workflows/devdocs-notify.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,26 @@ jobs:
99
notify_slack_on_issue:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- name: Send Slack Notification for New Issue
12+
- name: Send Slack Notification
1313
env:
14-
ISSUE_TITLE: ${{ github.event.issue.title }}
15-
ISSUE_USER: ${{ github.event.issue.user.login }}
16-
ISSUE_URL: ${{ github.event.issue.html_url }}
14+
# We use || to ensure this works for both 'issues' and 'pull_request' events
15+
EVENT_TITLE: ${{ github.event.issue.title || github.event.pull_request.title }}
16+
EVENT_USER: ${{ github.event.issue.user.login || github.event.pull_request.user.login }}
17+
EVENT_URL: ${{ github.event.issue.html_url || github.event.pull_request.html_url }}
1718
REPO_NAME: ${{ github.repository }}
1819
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
1920
run: |
20-
# Build message text using jq to safely handle user input
21-
MESSAGE_TEXT=$(jq -n \
22-
--arg repo "$REPO_NAME" \
23-
--arg title "$ISSUE_TITLE" \
24-
--arg user "$ISSUE_USER" \
25-
--arg url "$ISSUE_URL" \
26-
"📢 @DevDocs a PR was opened or issue created in \($repo)\n*Title:* \($title)\n*By:* \($user)\n*URL:* \($url)"
27-
}')
28-
29-
# Build Slack payload
21+
# Build Slack payload safely in one step to avoid quoting errors
3022
SLACK_PAYLOAD=$(jq -n \
31-
--arg text "$MESSAGE_TEXT" \
23+
--arg repo "$REPO_NAME" \
24+
--arg title "$EVENT_TITLE" \
25+
--arg user "$EVENT_USER" \
26+
--arg url "$EVENT_URL" \
3227
'{
3328
"channel": "#docs-devdocs-notifications",
3429
"username": "Issue Notifier",
3530
"icon_emoji": ":mega:",
36-
"text": $text
31+
"text": "📢 @DevDocs a PR was opened or issue created in \($repo)\n*Title:* \($title)\n*By:* \($user)\n*URL:* \($url)"
3732
}')
3833
3934
# Send to Slack

0 commit comments

Comments
 (0)