GitHub Actions の self-hosted runner における cache service v2
#GitHub_Actions
GitHub.com (GHEC)
GitHub.com で workflow を実行すると、GitHub Actions cache は Azure Blob Storage に保管される
GitHub-hosted runner の実体は Azure にデプロイされているため network 的に近い(たぶん)ので高速だが、self-hosted runner ではだいぶ低速になってしまう
しかし GitHub.com では cache service をカスタムする方法が公式には提供されていない
したがって storage も変更できない
ワークアラウンド
custom action
が、setup-foobar が勝手にやる依存関係やビルド成果物のキャッシュはどうにもできない
GitHub-hosted cache service にあるようなブランチ単位のアクセス制御も真面目にやるの大変そう
IAM policy で頑張ればいけるか?
https://github.com/whywaita/actions-cache-s3
S3 を cache の backend として使うアクション
custom cache service & storage
cache service
custom cache service by patching runner image
https://github.com/actions/toolkit/blob/ddc5fa4ae84a892bfa8431c353db3cf628f1235d/packages/cache/src/internal/config.ts#L22-L39
cacher service の URL ACTIONS_RESULTS_URL は、runner の image に含まれるバイナリにハードコードされている
https://gha-cache-server.falcondev.io/
バイナリに頑張って patch を当てている
https://gha-cache-server.falcondev.io/getting-started#docker
このあたりに頑張って patch を当てて自分で image を build するのもアリかもしれない
https://github.com/search?q=repo%3Aactions%2Frunner+ACTIONS_RESULTS_URL&type=code
custom http(s) proxy on self-hosted runner
self-hosted runner で https_proxy 環境変数を設定することで、https://github.com/actions/toolkit にプロキシを経由してサーバにアクセスさせることができる
https://docs.github.com/en/actions/how-tos/manage-runners/self-hosted-runners/use-proxy-servers#configuring-a-proxy-server-using-environment-variables
storage
Azure Blob Storage っぽい URL じゃないと concurrent download してくれない
https://github.com/actions/toolkit/blob/ddc5fa4ae84a892bfa8431c353db3cf628f1235d/packages/cache/src/internal/cacheHttpClient.ts#L145-L175
GHES
GHES では、enterprise server の管理者が Amazon S3 や Google Cloud Storage といった object storage にデータを保管するように設定できる
https://docs.github.com/en/enterprise-server@3.10/admin/managing-github-actions-for-your-enterprise/enabling-github-actions-for-github-enterprise-server/enabling-github-actions-with-amazon-s3-storage
https://docs.github.com/en/enterprise-server@3.10/admin/managing-github-actions-for-your-enterprise/enabling-github-actions-for-github-enterprise-server/enabling-github-actions-with-google-cloud-storage