From b290a8e3ae846c125cfe086d9af9c7cfc5c61c21 Mon Sep 17 00:00:00 2001 From: Martin Treml Date: Mon, 8 Jul 2024 11:34:07 +0200 Subject: [PATCH] Reuse github actions workflows to run docker image generation on each push and release --- .github/workflows/ci.yml | 29 ++++++++++++++++++++++++++ .github/workflows/docker.yml | 13 +++--------- .github/workflows/release.yml | 9 ++++++++ .github/workflows/{go.yml => test.yml} | 28 +++++++------------------ 4 files changed, 48 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml rename .github/workflows/{go.yml => test.yml} (72%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..e5aa5da6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: CI + +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + docker: + name: 'Run docker image building' + uses: ./.github/workflows/docker.yml + test: + name: 'Run tests and linting' + strategy: + fail-fast: false # Run the whole matrix for maximum information, no matter if we fail in one entry early + matrix: + os: + - 'macOS-latest' + - 'ubuntu-latest' + - 'windows-latest' + uses: ./.github/workflows/test.yml + with: + os: ${{ matrix.os }} + needs: docker diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e8f6bfde..8da9e55a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,13 +1,5 @@ -name: docker image - on: - push: - release: - types: [released] - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + workflow_call: jobs: docker: @@ -32,10 +24,11 @@ jobs: images: | ghcr.io/symflower/eval-dev-quality tags: | + type=raw,value={{ sha }} type=raw,value={{ branch }} type=raw,value=latest,enable={{ is_default_branch }} - name: Build and push - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: ./ platforms: linux/amd64 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..ed1ff239 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,9 @@ +name: Release + +on: + release: + types: [released] + +jobs: + docker: + uses: ./.github/workflows/docker.yml diff --git a/.github/workflows/go.yml b/.github/workflows/test.yml similarity index 72% rename from .github/workflows/go.yml rename to .github/workflows/test.yml index 6006b3e1..e097d2f7 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/test.yml @@ -1,26 +1,12 @@ -name: CI - on: - push: - branches: ['main'] - pull_request: - branches: ['main'] - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - + workflow_call: + inputs: + os: + required: true + type: string jobs: - ci: - name: 'Run CI' - strategy: - fail-fast: false # Run the whole matrix for maximum information, no matter if we fail in one entry early - matrix: - os: - - 'macOS-latest' - - 'ubuntu-latest' - - 'windows-latest' - runs-on: ${{ matrix.os }} + test: + runs-on: ${{ inputs.os }} steps: - uses: actions/checkout@v4