From 5aaa2ff64494293a5fd4a5eed5f5b833560f0929 Mon Sep 17 00:00:00 2001 From: Jason Cho Date: Fri, 1 Dec 2023 09:33:03 -0800 Subject: [PATCH] replace build-and-publish workflow Signed-off-by: Jason Cho --- .github/workflows/build-and-publish.yaml | 50 ++++++++++++++++-------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-and-publish.yaml b/.github/workflows/build-and-publish.yaml index dadf19fb7..c47bb6d8c 100644 --- a/.github/workflows/build-and-publish.yaml +++ b/.github/workflows/build-and-publish.yaml @@ -1,28 +1,41 @@ -# NOTE: set the REGISTRY secret to your own quay.io account in your fork to -# test this workflow! ---- name: Build and Publish Images on: - workflow_dispatch: - inputs: - tag: - description: 'Image tag. Defaults to 3.0.2' - required: false - default: "3.0.2" + push: + branches: + - 'main' + tags: # run on any tag that starts with `v` but not tags that end with `-downstream` + - 'v**' + - '!v**-downstream' jobs: build-and-publish: name: Build and Publish runs-on: ubuntu-latest - env: - TAG: ${{ github.event.inputs.tag || '3.0.2' }} steps: - - name: Check out code - uses: actions/checkout@v3 + # Get the repository's code + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + quay.io/project-koku/koku-metrics-operator + tags: | + type=semver,pattern={{raw}} + type=sha,prefix=,enable=${{ github.ref_type == 'tag' }} + # set latest tag for default branch + type=raw,value=latest + type=ref,event=branch - name: Login to Quay.io uses: redhat-actions/podman-login@v1 @@ -31,5 +44,10 @@ jobs: username: ${{ secrets.QUAY_USER }} password: ${{ secrets.QUAY_TOKEN }} - - name: Build and Publish - run: make docker-buildx IMG=quay.io/project-koku/koku-metrics-operator:${{ env.TAG }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/arm64,linux/amd64,linux/s390x,linux/ppc64le + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }}