API Reference: Add a "See Also" pointing to the corresponding User Guide #320
Workflow file for this run
This file contains 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 by a branch | |
on: | |
pull_request: | |
types: | |
- closed | |
workflow_dispatch: | |
inputs: | |
pull_request_number: | |
description: 'Run on pull request number' | |
required: false | |
type: string | |
jobs: | |
cleanup: | |
runs-on: ubuntu-latest | |
permissions: | |
actions: write | |
steps: | |
- name: Cleanup | |
run: | | |
gh extension install actions/gh-actions-cache | |
REPO=${{ github.repository }} | |
BRANCH=${{ env.PULL_REQUEST_NUMBER && format('refs/pull/{0}/merge', env.PULL_REQUEST_NUMBER) || github.ref }} | |
## Setting this to not fail the workflow while deleting cache keys. | |
set +e | |
echo "Deleting caches..." | |
while [[ $(gh actions-cache list -R $REPO -B $BRANCH | grep -v 'no Actions caches') ]] | |
do | |
gh actions-cache list -R $REPO -B $BRANCH --limit=100 | cut -f 1 | xargs -I{} gh actions-cache delete {} -R $REPO -B $BRANCH --confirm | |
done | |
echo "Done" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number || inputs.pull_request_number }} |