@@ -10,29 +10,33 @@ jobs:
1010 runs-on : ubuntu-latest
1111 steps :
1212 - name : Check for new PR or issues
13- uses : actions/github-script@v7
14- with :
15- script : |
16- const text = context.payload.comment?.body
17- || context.payload.issue?.body
18- || context.payload.pull_request?.body
19- || context.payload.review?.body
20- || "";
13+ env :
14+ ISSUE_TITLE : ${{ github.event.issue.title }}
15+ ISSUE_USER : ${{ github.event.issue.user.login }}
16+ ISSUE_URL : ${{ github.event.issue.html_url }}
17+ REPO_NAME : ${{ github.repository }}
18+ SLACK_WEBHOOK : ${{ secrets.SLACK_WEBHOOK_URL }}
19+ 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) 📢*')
2127
22- const url = process.env.SLACK_WEBHOOK_URL;
23- console.log("Slack URL Length", url?.length);
28+ # Build Slack payload
29+ SLACK_PAYLOAD=$(jq -n \
30+ --arg text "$MESSAGE_TEXT" \
31+ '{
32+ "channel": "#docs-devdocs-notifications",
33+ "username": "Issue Notifier",
34+ "icon_emoji": ":mega:",
35+ "text": $text
36+ }')
2437
25- await fetch(process.env.SLACK_WEBHOOK_URL, {
26- method: "POST",
27- headers: { "Content-Type": "application/json" },
28- body: JSON.stringify({
29- text: `:eyes: @DevDocs a PR was opened or issue created in *${context.payload.repository.full_name}*
30- Event: *${context.eventName}*
31- Link: ${context.payload.comment?.html_url
32- || context.payload.issue?.html_url
33- || context.payload.pull_request?.html_url
34- || context.payload.review?.html_url}`
35- }),
36- });
37- env :
38- SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
38+ # Send to Slack
39+ curl -X POST \
40+ -H 'Content-type: application/json' \
41+ --data "$SLACK_PAYLOAD" \
42+ "$SLACK_WEBHOOK"
0 commit comments