From d540f441195d540ca575170c6541676a428d007d Mon Sep 17 00:00:00 2001 From: Justin Downie <55856631+jdowni000@users.noreply.github.com> Date: Tue, 12 Sep 2023 09:50:04 -0500 Subject: [PATCH] Fix Tag scenarios (#74) * Initial commit * Remove env * Try env instead of input * Add labels to docker buildx * Add quay.expires-after * Add metadata action * Attempt to format to list for labels * Add metadata with image * Single label test * Format for list * Revert back and test * Image tag for main * Remove hash from main * Make latest tag for release as well * Fix syntax error * Attempt to fix if cond * Switch release build order, format * Test operators * Test each expression * Boolean returns 1 or 0 for diff types test * Seperate if conditions * Explicity bool * Try to make expression a bool * Remove $ --- .github/workflows/reusable_workflow.yaml | 26 +++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/reusable_workflow.yaml b/.github/workflows/reusable_workflow.yaml index edb9045..a5d9392 100644 --- a/.github/workflows/reusable_workflow.yaml +++ b/.github/workflows/reusable_workflow.yaml @@ -44,6 +44,11 @@ jobs: run: | echo "IMAGE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set image tag for main + if: github.ref == 'refs/heads/main' && github.event_name != 'release' + run: | + echo "IMAGE_TAG=main_latest" >> $GITHUB_ENV + - name: Set image tag and expiration for dev if: github.ref != 'refs/heads/main' && github.event_name != 'release' run: | @@ -74,11 +79,11 @@ jobs: archetype: ${{ inputs.archetype }} req_check_only: ${{ inputs.multi_arch }} - - name: Set up Docker Buildx for Multi-Arch + - name: Set up Docker Buildx for multi-arch if: ${{ inputs.multi_arch }} uses: docker/setup-buildx-action@v2 - - name: Login to Quay for Multi-Arch + - name: Login to Quay for multi-arch if: ${{ inputs.multi_arch }} uses: docker/login-action@v2 with: @@ -86,11 +91,22 @@ jobs: username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_PASSWORD }} - - name: Build and push for Multi-Arch - if: ${{ inputs.multi_arch }} + - name: Build and push multi-arch image for release + if: github.event_name == 'release' && inputs.multi_arch == true + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: quay.io/${{ secrets.QUAY_NAMESPACE }}/${{ inputs.image_name }}:${{ env.IMAGE_TAG }}, + quay.io/${{ secrets.QUAY_NAMESPACE }}/${{ inputs.image_name }}:latest + + - name: Build and push multi-arch image + if: github.event_name != 'release' && inputs.multi_arch == true uses: docker/build-push-action@v4 with: context: . platforms: linux/amd64,linux/arm64 push: true - tags: "quay.io/${{ secrets.QUAY_NAMESPACE }}/${{ inputs.image_name }}:${{ inputs.image_tag }}" + tags: quay.io/${{ secrets.QUAY_NAMESPACE }}/${{ inputs.image_name }}:${{ env.IMAGE_TAG }} + labels: quay.expires-after=${{ env.QUAY_IMG_EXP }}