Skip to content

Commit

Permalink
branch ID for CI cache isolation
Browse files Browse the repository at this point in the history
  • Loading branch information
mroth committed Apr 30, 2019
1 parent ae04ba8 commit f8d3918
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/main.workflow
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ action "Docker Registry Login" {

action "Caching Build" {
uses = "actions/docker/cli@master"
runs = ["sh", "-c", "BRANCH=gh-${GITHUB_REF##*/} ci/build.sh"]
runs = ["sh", "-c", "BRANCH=${GITHUB_REF##*/} ID=gh ci/build.sh"]
needs = ["Docker Registry Login"]
env = {
PUSH_CACHE = "1"
Expand Down
12 changes: 8 additions & 4 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# In the (hopefully not-so-distant) future, Docker BuildKit should enable easier
# storage of a distributed cache system shared amongst serverless workers
# without this hack.
set -e

# Allow passing a $REMOTE_IMAGE variable if the remote image tag will be
# different (e.g. pushing somewhere other than Docker Hub).
Expand All @@ -35,10 +36,13 @@ BRANCH=${BRANCH:-$(git rev-parse --abbrev-ref HEAD)}
# able to fall back to the last master branch build in the situation where
# this is the first build for a new branch/PR, so we don't start from scratch
# in that situation.
BUILDER_MASTER_TAG="${REMOTE_IMAGE}:builder-buildcache-master"
BUILDER_BRANCH_TAG="${REMOTE_IMAGE}:builder-buildcache-${BRANCH}"
PACKAGER_MASTER_TAG="${REMOTE_IMAGE}:packager-buildcache-master"
PACKAGER_BRANCH_TAG="${REMOTE_IMAGE}:packager-buildcache-${BRANCH}"
#
# Allow for an optional ID tag to isolate caches.
ID=${ID:-"ol"}
BUILDER_MASTER_TAG="${REMOTE_IMAGE}:builder-buildcache-${ID}-master"
BUILDER_BRANCH_TAG="${REMOTE_IMAGE}:builder-buildcache-${ID}-${BRANCH}"
PACKAGER_MASTER_TAG="${REMOTE_IMAGE}:packager-buildcache-${ID}-master"
PACKAGER_BRANCH_TAG="${REMOTE_IMAGE}:packager-buildcache-${ID}-${BRANCH}"

# Pull previous cached image(s) from remote docker registry.
docker pull "$BUILDER_MASTER_TAG" || true
Expand Down

0 comments on commit f8d3918

Please sign in to comment.