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>
This commit is contained in:
parent
82d6efe37c
commit
e644ab71fa
44
.github/workflows/webhook-caller.yml
vendored
Normal file
44
.github/workflows/webhook-caller.yml
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
name: Call Webhooks on Main Push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
actions: none
|
||||
checks: none
|
||||
deployments: none
|
||||
issues: none
|
||||
discussions: none
|
||||
packages: none
|
||||
pull-requests: none
|
||||
repository-projects: none
|
||||
security-events: none
|
||||
statuses: none
|
||||
|
||||
jobs:
|
||||
call-webhooks:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check and call webhooks
|
||||
env:
|
||||
WEBHOOK_URLS: ${{ secrets.WEBHOOK_URLS }}
|
||||
run: |
|
||||
if [ -n "$WEBHOOK_URLS" ]; then
|
||||
IFS=',' read -ra URLS <<< "$WEBHOOK_URLS"
|
||||
idx=1
|
||||
for url in "${URLS[@]}"; do
|
||||
if [[ "$url" =~ ^https:// ]]; then
|
||||
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
|
||||
echo "Webhook call failed for URL '$url' at index $idx" >&2
|
||||
fi
|
||||
else
|
||||
echo "Skipping invalid webhook URL (must start with https://): '$url' at index $idx" >&2
|
||||
fi
|
||||
idx=$((idx+1))
|
||||
done
|
||||
else
|
||||
echo "No webhooks to call."
|
||||
fi
|
||||
Loading…
x
Reference in New Issue
Block a user