From e644ab71fab53e89ec3c45183768048574eec494 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Mon, 28 Jul 2025 09:53:17 +1000 Subject: [PATCH] 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> --- .github/workflows/webhook-caller.yml | 44 ++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/webhook-caller.yml diff --git a/.github/workflows/webhook-caller.yml b/.github/workflows/webhook-caller.yml new file mode 100644 index 0000000..45f1d08 --- /dev/null +++ b/.github/workflows/webhook-caller.yml @@ -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