From 97ef92706babf3473cc18764a7904bebcd76e18e Mon Sep 17 00:00:00 2001 From: Lionel ORRY Date: Thu, 17 Jul 2025 12:45:35 +0200 Subject: [PATCH] refactor workflows to enable multiple docker images --- .github/workflows/build-and-push.yml | 23 +++++++++++++---------- .github/workflows/trigger-manual.yml | 19 +++++++++++++++++++ .github/workflows/trigger-nightly.yml | 13 +++++++++++++ 3 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/trigger-manual.yml create mode 100644 .github/workflows/trigger-nightly.yml diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 475ec651..7f24431e 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -1,14 +1,16 @@ -name: "Build GARM images" +name: "Build and push GARM images" on: - workflow_dispatch: + workflow_call: inputs: push_to_project: description: "Project to build images for" required: true + type: string default: "ghcr.io/cloudbase" ref: description: "Ref to build" required: true + type: string default: "main" schedule: - cron: "0 2 * * *" @@ -24,8 +26,9 @@ jobs: runs-on: ubuntu-latest steps: - name: "Checkout" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: + ref: ${{ inputs.ref }} path: src/github.com/cloudbase/garm fetch-depth: 0 @@ -40,15 +43,12 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push + env: + REGISTRY_INPUT: ${{ inputs.push_to_project }} + GH_REF: ${{ inputs.ref }} + working-directory: src/github.com/cloudbase/garm run: | set -x - REGISTRY_INPUT="${{ github.event.inputs.push_to_project }}" - REF_INPUT="${{ github.event.inputs.ref }}" - - PUSH_TO_PROJECT="${REGISTRY_INPUT:-ghcr.io/cloudbase}" - GH_REF="${REF_INPUT:-main}" - cd src/github.com/cloudbase/garm && git checkout "${GH_REF}" - VERSION=$(git describe --tags --match='v[0-9]*' --always) AZURE_REF=v0.1.0 OPENSTACK_REF=v0.1.0 @@ -69,6 +69,9 @@ jobs: K8S_REF="main" VERSION="nightly" fi + if [ "$GH_REF" == "release/v1" ]; then + VERSION="v0.1" + fi docker buildx build \ --provenance=false \ --platform linux/amd64,linux/arm64 \ diff --git a/.github/workflows/trigger-manual.yml b/.github/workflows/trigger-manual.yml new file mode 100644 index 00000000..faf166d4 --- /dev/null +++ b/.github/workflows/trigger-manual.yml @@ -0,0 +1,19 @@ +name: Manual build of GARM images +on: + workflow_dispatch: + inputs: + push_to_project: + description: "Project to build images for" + required: true + default: "ghcr.io/cloudbase" + ref: + description: "Ref to build" + required: true + default: "main" + +jobs: + call-build-and-push: + uses: ./.github/workflows/build-and-push.yml + with: + push_to_project: ${{ inputs.push_to_project }} + ref: ${{ inputs.ref }} \ No newline at end of file diff --git a/.github/workflows/trigger-nightly.yml b/.github/workflows/trigger-nightly.yml new file mode 100644 index 00000000..79c42228 --- /dev/null +++ b/.github/workflows/trigger-nightly.yml @@ -0,0 +1,13 @@ +name: Nightly build of GARM images +on: + schedule: + - cron: "0 2 * * *" + +jobs: + call-build-and-push: + uses: ./.github/workflows/build-and-push.yml + strategy: + matrix: + ref: ["main", "release/v1"] + with: + ref: ${{ matrix.ref }}