AG-16398 - Workaround for sync tooltips. #5394
Workflow file for this run
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: Cleanup caches on PR close | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| permissions: | |
| contents: read | |
| jobs: | |
| cleanup: | |
| runs-on: ubuntu-24.04 | |
| env: | |
| SNAPSHOT_BRANCH: 'gha/snapshots-${{ github.head_ref }}' | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v4 | |
| - name: Cleanup | |
| run: | | |
| gh extension install actions/gh-actions-cache | |
| echo "SNAPSHOT_BRANCH: ${{env.SNAPSHOT_BRANCH}}" | |
| REPO=${{ github.repository }} | |
| BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" | |
| echo "Fetching list of cache keys" | |
| cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) | |
| ## Setting this to not fail the workflow while deleting cache keys. | |
| set +e | |
| echo "Deleting caches..." | |
| for cacheKey in $cacheKeysForPR | |
| do | |
| echo "Deleting cache... $cacheKey" | |
| gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm | |
| done | |
| echo "Done" | |
| echo "Cleaning up any auto-generated branches." | |
| if (git ls-remote --exit-code --heads origin ${{env.SNAPSHOT_BRANCH}} >/dev/null) ; then | |
| git push -d origin ${{env.SNAPSHOT_BRANCH}} | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |