Skip to content

Commit

Permalink
ci: try spedup build
Browse files Browse the repository at this point in the history
  • Loading branch information
TimVosch committed Jun 25, 2024
1 parent 7609362 commit bfd7882
Showing 1 changed file with 14 additions and 39 deletions.
53 changes: 14 additions & 39 deletions .github/workflows/build-docker-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
test:
name: Run Go Tests
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -26,47 +25,20 @@ jobs:
with:
go-version-file: ./go.mod

- name: Run Go Tests
run: go test ./...

docker-cache:
name: Build cache image
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Log in to GHCR
uses: docker/login-action@v3
- name: Cache Go modules
uses: actions/cache@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.cache
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ env.BUILDCACHE_TAG }}
cache-from: type=registry,ref=${{ env.BUILDCACHE_TAG }}
cache-to: type=registry,ref=${{ env.BUILDCACHE_TAG }},mode=max
- name: Run Go Tests
run: go test ./...

docker:
name: Build images
needs: docker-cache
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -128,12 +100,15 @@ jobs:
type=semver,pattern={{version}}
- name: Build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.BUILDCACHE_TAG }}
cache-from: |
type=registry,ref=${{ env.REGISTRY }}/${{ matrix.image }}:buildcache
cache-to: |
type=registry,ref=${{ env.REGISTRY }}/${{ matrix.image }}:buildcache,mode=max

0 comments on commit bfd7882

Please sign in to comment.