Closed LukeAI closed 1 year ago
Is it possible to have the multistage build cache shared across all branches in a repo ?
Don't think so across all branches, there are restrictions with GitHub Cache access: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache.
for every new PR which is expensive in terms of time, things it has to download etc.
If PR has the base branch with cache populated it should work. Per GitHub docs:
If a workflow run is triggered for a pull request, it can also restore caches created in the base branch, including base branches of forked repositories. For example, if the branch feature-b has the base branch feature-a, a workflow run triggered on a pull request would have access to caches created in the default main branch, the base feature-a branch, and the current feature-b branch.
You can check the GitHub cache scopes in your logs (see GitHub Actions runtime token ACs
group). For example this PR https://github.com/docker/build-push-action/pull/830 has the following access: https://github.com/docker/build-push-action/actions/runs/4729816108/jobs/8392750430?pr=830#step:6:19
GitHub Actions runtime token ACs
refs/pull/830/merge: read/write
refs/heads/master: read
And as you can see can read cache from its base branch:
Don't think so across all branches, there are restrictions with GitHub Cache access
What about using GitHub's container registry as a cache instead? Then sharing across branch should work, or?
Hi! I have a large multistage docker build, invoked as below. based on this discussion https://github.com/docker/build-push-action/issues/286 It successfully caches and reuses the different layers as needed - typically the last stage will rerun because of slightly different dependencies defined in the codebase. BUT the build cache is not shared across branches - so the container has to be built from scratch for every new PR which is expensive in terms of time, things it has to download etc.
Is it possible to have the multistage build cache shared across all branches in a repo ?