Created
May 1, 2025 21:02
-
-
Save brandonc/80a571910239ed2b010c5f87f84b45dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/request-action@v2.x | |
| 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/request-action@v2.x | |
| 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