Skip to content

Commit

Permalink
GITHUB: workflows/testing.yml: configure and use buildx with selectiv…
Browse files Browse the repository at this point in the history
…e caching

Signed-off-by: Tim Janik <[email protected]>
  • Loading branch information
tim-janik committed Sep 11, 2023
1 parent 6362abb commit 7e3056c
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@ jobs:
steps:
# Checkout and fix actions/checkout messing up annotation of the fetched tag: actions/checkout#290
- uses: actions/checkout@v4
with: { fetch-depth: 0, show-progress: false }
- run: git fetch -f --tags
# Docker build - use BuildKit and Github action API for reliable caching
- uses: docker/[email protected]
- run: docker buildx create --use --driver=docker-container # multi-platform, exports cache, needs --load
- uses: docker/build-push-action@v4
with: # docker build -t cifocal:latest -f misc/Dockerfile.focal misc
tags: cifocal:latest
file: misc/Dockerfile.focal
context: misc/
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
- run: git fetch --unshallow && git fetch -f --tags
# Use either cache-from or cache-to, so buildx cannot mess up good caches
- uses: actions/cache@v3
with:
key: cifocal-${{hashFiles ('misc/Dockerfile.focal')}}
path: /tmp/acache
- name: Docker Build cifocal
run: |
docker buildx create --use --driver=docker-container # multi-platform, exports cache, needs --load
test -r /tmp/acache/index.json && CACHETYPE=--cache-from=type=local,src=/tmp/acache || CACHETYPE=--cache-to=type=local,mode=max,dest=/tmp/acache
time docker buildx build $CACHETYPE --load -t $CITAG -f misc/Dockerfile.focal misc
# Build Assets
- name: Build Assets
run: |
Expand All @@ -51,20 +49,17 @@ jobs:
steps:
# Checkout and fix actions/checkout messing up annotation of the fetched tag: actions/checkout#290
- uses: actions/checkout@v4
- run: git fetch --unshallow && git fetch -f --tags
# Use either cache-from or cache-to, so buildx cannot mess up good caches
- uses: actions/cache@v3
with:
path: /tmp/aca/
key: Focal-${{ hashFiles ('misc/Dockerfile.focal') }}
- uses: docker/[email protected] # Use BuildKit for reliable caching
- run: docker buildx create --use --driver=docker-container # multi-platform, exports cache, needs --load
- uses: docker/build-push-action@v4
with: # docker build -t cifocal:latest -f misc/Dockerfile.focal misc
tags: cifocal:latest
file: misc/Dockerfile.focal
context: misc/
cache-from: type=local,src=/tmp/aca/
cache-to: type=local,dest=/tmp/aca/,mode=max
load: true
key: cifocal-${{hashFiles ('misc/Dockerfile.focal')}}
path: /tmp/acache
- name: Docker Build cifocal
run: |
docker buildx create --use --driver=docker-container # multi-platform, exports cache, needs --load
test -r /tmp/acache/index.json && CACHETYPE=--cache-from=type=local,src=/tmp/acache || CACHETYPE=--cache-to=type=local,mode=max,dest=/tmp/acache
time docker buildx build $CACHETYPE --load -t $CITAG -f misc/Dockerfile.focal misc
# Build Assets
- name: Build Assets
run: |
Expand Down

0 comments on commit 7e3056c

Please sign in to comment.