Skip to content

Commit e644ab7

Browse files
aaronpowellCopilot
andauthored
Adding an action to invoke webhooks (#78)
* Adding an action to invoke webhooks This will allow external tools to be notified when there are updates on the main branch so they can request the data from the repo * Addressing some feedback * Changing the log messages * Cleaning up log message * Update .github/workflows/webhook-caller.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/webhook-caller.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/webhook-caller.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 82d6efe commit e644ab7

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Call Webhooks on Main Push
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
actions: none
11+
checks: none
12+
deployments: none
13+
issues: none
14+
discussions: none
15+
packages: none
16+
pull-requests: none
17+
repository-projects: none
18+
security-events: none
19+
statuses: none
20+
21+
jobs:
22+
call-webhooks:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Check and call webhooks
26+
env:
27+
WEBHOOK_URLS: ${{ secrets.WEBHOOK_URLS }}
28+
run: |
29+
if [ -n "$WEBHOOK_URLS" ]; then
30+
IFS=',' read -ra URLS <<< "$WEBHOOK_URLS"
31+
idx=1
32+
for url in "${URLS[@]}"; do
33+
if [[ "$url" =~ ^https:// ]]; then
34+
if ! curl -f --max-time 30 --retry 3 --silent --show-error -X POST -H "User-Agent: webhook-caller" -H "Content-Type: application/json" "$url"; then
35+
echo "Webhook call failed for URL '$url' at index $idx" >&2
36+
fi
37+
else
38+
echo "Skipping invalid webhook URL (must start with https://): '$url' at index $idx" >&2
39+
fi
40+
idx=$((idx+1))
41+
done
42+
else
43+
echo "No webhooks to call."
44+
fi

0 commit comments

Comments
 (0)