@@ -108,7 +108,7 @@ jobs:
108108 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
109109 REPO : ${{ github.repository }}
110110 run : |
111- RUN_ID=$(gh run list --repo "$REPO" --workflow "Dependabot Updates" --status success --limit 30 --json databaseId,name --jq '[ .[] | select(.name | startswith("npm_and_yarn"))][0] .databaseId')
111+ RUN_ID=$(gh run list --repo "$REPO" --workflow "Dependabot Updates" --status success --limit 30 --json databaseId,name --jq 'first( .[] | select(.name | startswith("npm_and_yarn")) | .databaseId) // empty ')
112112 echo "run_id=$RUN_ID" >> "$GITHUB_OUTPUT"
113113
114114 - name : Extract stuck deps (only if actions pending)
@@ -139,13 +139,34 @@ jobs:
139139 LIST=$(echo "$STUCK" | awk 'NR>1{printf "\\n"} {printf "• *%s* %s", $1, $2}')
140140 echo "section=${HEADER}${LIST}" >> "$GITHUB_OUTPUT"
141141
142+ - name : Build Slack payload
143+ env :
144+ REPO : ${{ github.repository }}
145+ CHANNEL : ${{ vars.SLACK_CHANNEL_ID }}
146+ TOTAL : ${{ steps.alerts.outputs.total }}
147+ BY_SEVERITY : ${{ steps.alerts.outputs.by_severity }}
148+ PRS_LIST : ${{ steps.prs.outputs.list }}
149+ ACTIONS : ${{ steps.alerts.outputs.actions }}
150+ STUCK : ${{ steps.stuck.outputs.section }}
151+ run : |
152+ # Build payload via jq so PR titles or error strings containing
153+ # quotes/backslashes/newlines can't break the JSON.
154+ jq -n \
155+ --arg channel "$CHANNEL" \
156+ --arg repo "$REPO" \
157+ --arg total "$TOTAL" \
158+ --arg by_severity "$BY_SEVERITY" \
159+ --arg prs_list "$PRS_LIST" \
160+ --arg actions "$ACTIONS" \
161+ --arg stuck "$STUCK" \
162+ '{
163+ channel: $channel,
164+ text: ":calendar: *Weekly Dependabot summary* - `\($repo)`\n\n*Open alerts (\($total)):*\n\($by_severity)\n\n*Open Dependabot PRs:*\n\($prs_list)\n\n*Actions needed (<7d remaining):*\n\($actions)\($stuck)\n\n<https://github.com/\($repo)/security/dependabot|Dependabot alerts>"
165+ }' > payload.json
166+
142167 - name : Post Slack summary
143168 uses : slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3
144169 with :
145170 method : chat.postMessage
146171 token : ${{ secrets.SLACK_BOT_TOKEN }}
147- payload : |
148- {
149- "channel": "${{ vars.SLACK_CHANNEL_ID }}",
150- "text": ":calendar: *Weekly Dependabot summary* - `${{ github.repository }}`\n\n*Open alerts (${{ steps.alerts.outputs.total }}):*\n${{ steps.alerts.outputs.by_severity }}\n\n*Open Dependabot PRs:*\n${{ steps.prs.outputs.list }}\n\n*Actions needed (<7d remaining):*\n${{ steps.alerts.outputs.actions }}${{ steps.stuck.outputs.section }}\n\n<https://github.com/${{ github.repository }}/security/dependabot|Dependabot alerts>"
151- }
172+ payload-file-path : payload.json
0 commit comments