Skip to content

Commit

Permalink
CI: Update GA to use cache
Browse files Browse the repository at this point in the history
  • Loading branch information
TimVosch committed May 22, 2024
1 parent 53176cf commit 9399a92
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions .github/workflows/build-docker-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
BUILDCACHE_TAG: ${{ env.REGISTRY }}/gacache:${{ github.sha }}

jobs:
test:
Expand All @@ -28,11 +29,46 @@ jobs:
- 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@v3

- 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
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: services/core/Dockerfile
target: builder
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

docker:
name: Build images
needs: test
needs: docker-cache
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/main' && 'staging' || (github.ref == 'refs/tags/*' && 'production' || '') }}
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -110,3 +146,4 @@ jobs:
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.BUILDCACHE_TAG }}

0 comments on commit 9399a92

Please sign in to comment.