Skip to content

Instantly share code, notes, and snippets.

@brandonc
Created May 1, 2025 21:02
Show Gist options
  • Save brandonc/80a571910239ed2b010c5f87f84b45dd to your computer and use it in GitHub Desktop.
Save brandonc/80a571910239ed2b010c5f87f84b45dd to your computer and use it in GitHub Desktop.
name: Delete All Webhooks
on:
workflow_dispatch:
workflow_call:
secrets:
GH_TOKEN:
required: true
schedule:
- cron: '0 0 * * SAT'
jobs:
fetchWebhooks:
runs-on: ubuntu-latest
outputs:
hook_ids: ${{ steps.format.outputs.hook_ids }}
steps:
- uses: octokit/[email protected]
id: request
with:
route: GET /repos/${{ github.repository }}/hooks
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- id: format
run: |
echo "hook_ids=$(jq -n '${{ steps.request.outputs.data }}' | jq -rc '[.[] .id]')\n" >> $GITHUB_OUTPUT
- run: |
echo 'Deleting these webhook ids: ${{ steps.format.outputs.hook_ids }}'
cleanWebhooks:
runs-on: ubuntu-latest
needs: [ fetchWebhooks ]
if: fromJSON(needs.fetchWebhooks.outputs.hook_ids)[0] != null
strategy:
matrix:
value: ${{fromJSON(needs.fetchWebhooks.outputs.hook_ids)}}
steps:
- uses: octokit/[email protected]
id: delete_webhook
with:
route: DELETE /repos/${{ github.repository }}/hooks/${{ matrix.value }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment