LoginSignup
7
2

More than 1 year has passed since last update.

Github ActionsのキャッシュをGET/DELETEする

Last updated at Posted at 2022-08-04

actions/cacheでGithub Actions内にキャッシュされたデータを消したい場合、
現状ではUIから消すことはできず、Github APIを使って消す必要がある。

tl;dr

  1. Personal Access Token(PAT)を取得する
  2. Github CLIをインストールする
  3. 下のコマンドを実行して、Cacheを削除
$ gh api -X GET repos/{ORG}/{REPO}/actions/caches | jq '.actions_caches[] | select(.key == "${CACHE_ID}") | .id' | xargs -L1 -I{} gh api -X DELETE repos/{ORG}/{REPO}/actions/caches/{}

Requirements

  • GitHub CLI
    • Personal Access Tokenを発行し、 gh api が実行できるようにしておく。
  • jq

cacheリストの取得(GET)

$ gh api -X GET repos/{org}/{repo}/actions/caches/{CACHE_ID}

cacheの削除(DELETE)

keyidは異なるので注意。
keyはキャッシュの同一性判定に使われるもので、Actionsの画面に表示されている。

ここで指定するのはidなので、 GETエンドポイントでkeyからidを引く。

# 例:
# gh api -X DELETE repos/{ORG}/{REPO}/actions/caches/162
$ gh api -X DELETE repos/{ORG}/{REPO}/actions/caches/{CACHE_ID}
7
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
2