From b06b4e41a56c5236b1abb90a29efec01adcef249 Mon Sep 17 00:00:00 2001 From: Huy Mai Date: Thu, 5 Dec 2024 10:49:21 +0200 Subject: [PATCH] Make image build on releases Signed-off-by: Huy Mai --- .github/workflows/build-images-action.yml | 44 ++++++++++++++++------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-images-action.yml b/.github/workflows/build-images-action.yml index 2e44016e..574c98c4 100644 --- a/.github/workflows/build-images-action.yml +++ b/.github/workflows/build-images-action.yml @@ -6,20 +6,38 @@ permissions: on: push: branches: - - 'main' - - 'release-*' + - "main" + - "release-*" tags: - - 'v*' + - "v*" + workflow_run: + workflows: + - "Create Release" + types: + - completed jobs: build_ipam: - name: Build IPAM container image - if: github.repository == 'metal3-io/ip-address-manager' - uses: metal3-io/project-infra/.github/workflows/container-image-build.yml@main - with: - image-name: 'ip-address-manager' - pushImage: true - secrets: - QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }} - QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + runs-on: ubuntu-latest + steps: + - name: Set ref + id: set_ref + run: | + # Check if release_tag exists, if so, set ref to "refs/heads/${{ release_tag }}", otherwise use github.ref + if [[ -n "${{ needs.create-release.outputs.release_tag }}" ]]; then + echo "GITHUB_REF=refs/heads/${{ needs.create-release.outputs.release_tag }}" >> "${GITHUB_ENV}" + else + echo "GITHUB_REF=${{ github.ref }}" >> "${GITHUB_ENV}" + fi + + - name: Build IPAM container image + if: github.repository == 'metal3-io/ip-address-manager' + uses: metal3-io/project-infra/.github/workflows/container-image-build.yml@main + with: + image-name: "ip-address-manager" + pushImage: true + ref: ${{ env.GITHUB_REF }} + secrets: + QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }} + QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}