docker-build-cache-config-action
docker-build-cache-config-action copied to clipboard
Consider case of multiple image tags from branch
Problem to solve
For some branch strategy, CI builds multiple image tags from a branch with a different build-args or arch. Here are the example cases.
Different arch
- From
mainbranch, it buildsmain-amd64for amd64 architecture - From
mainbranch, it buildsmain-arm64for arm64 architecture
Different build-args
- From
mainbranch, it buildsdevelopmentwith the build-args - From
mainbranch, it buildsstagingwith the build-args
How to solve
Different arch
Set an architecture to the suffix to separate the cache tags.
- uses: int128/docker-build-cache-config-action@v1
with:
# e.g. main-arm64-cache
flavor: suffix=-${{ inputs.arch }}-cache
This works as follows:
- On push branch
- Import and export the cache tag of
main-arm64-cache
- Import and export the cache tag of
- On pull_request
- Import the cache tag of
main-arm64-cache
- Import the cache tag of
- On pull_request with
pull-request-cache- Export the cache tag of
pr-123-arm64-cache - Import the cache tag of
pr-123-arm64-cacheandmain-arm64-cache
- Export the cache tag of
- On other events
- Import the cache tag of
main-arm64-cache
- Import the cache tag of
Different build-args
- uses: int128/docker-build-cache-config-action@v1
with:
flavor: |
suffix=-${{ inputs.environment }}-cache
always-cache-from-tags: main-development-cache
For example,
- On push branch
- If the environment is development,
- Import and export the cache tag of
main-development-cache
- Import and export the cache tag of
- If the environment is staging,
- Import and export the cache tag of
main-staging-cache
- Import and export the cache tag of
- If the environment is development,
- On pull_request
- Import the cache tag of
main-development-cache
- Import the cache tag of
- On pull_request with
pull-request-cache- Export the cache tag of
pr-123--cache - Import the cache tag of
pr-123--cacheandmain-development-cache
- Export the cache tag of
- On other events
- Import the cache tag of
main-development-cache
- Import the cache tag of