アプリ開発備忘録

PlayStationMobile、Android、UWPの開発備忘録

GitHub Actionsで全てのキャッシュを削除する

現状(2023/11/07)、UIでは用意されていないのでworkflow_dispatchで動作させる。

name: cleanup all caches
on:
  workflow_dispatch:

jobs:
  cleanup:
    runs-on: ubuntu-latest
    steps:
      - name: Cleanup
        run: |
          gh extension install actions/gh-actions-cache
  
          set +e
          echo "Deleting caches..."
          gh actions-cache list -R $REPO -L 100 | while IFS=$'\t' read -r cacheKey _ branch _
          do
            gh actions-cache delete "$cacheKey" -R $REPO -B "$branch" --confirm
          done
          echo "Done"
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          REPO: ${{ github.repository }}

参考

ブランチ毎のコードを参考に改変 https://docs.github.com/ja/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries