Delete mirror branches #16395
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 mirror branches | |
| on: | |
| delete: | |
| permissions: | |
| # actions/checkout | |
| contents: read | |
| # Deletion step uses secrets.API_TOKEN_GITHUB, so no need for permissions. | |
| jobs: | |
| delete: | |
| name: Delete `${{ github.event.ref }}` | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 # 2025-11-20: Less than a minute. | |
| if: github.event_name == 'delete' && github.repository == 'Automattic/jetpack' && github.event.ref == 'prerelease' | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: trunk | |
| - name: Delete branches | |
| env: | |
| TOKEN: ${{ secrets.API_TOKEN_GITHUB }} | |
| REF: heads/${{ github.event.ref }} | |
| run: | | |
| for repo in $(jq -r '.extra["mirror-repo"] // empty' projects/*/*/composer.json | sort -u); do | |
| echo "::group::Deleting $REF on $repo" | |
| RES="$(curl -v -L -X DELETE --header "Authorization: Bearer $TOKEN" "https://api.github.com/repos/$repo/git/refs/$REF")" | |
| echo '::endgroup::' | |
| echo "$RES" | |
| done |