From 07c77302f5c3616f5c36421dead54fe444c9ce26 Mon Sep 17 00:00:00 2001 From: Vincent Capelle Date: Mon, 4 Nov 2024 13:41:20 -0500 Subject: [PATCH] Make workflow Docker builds smarter: - Enable cache for faster builds - Build on push, not PR, but also: - Cancel ongoing builds when a new one is triggered (except on main) - Scheduled weekly builds on main --- .github/workflows/build-docker-image.yml | 25 +++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 45138ef..1e26141 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -1,14 +1,29 @@ -name: Build Docker image +name: Build Docker image as test on: + schedule: + - cron: '12 17 * * FRI' push: - branches: [main] - pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: docker: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - run: docker build . + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build image + uses: docker/build-push-action@v6 + with: + context: . + push: false + pull: true + cache-from: type=gha + cache-to: type=gha,mode=max