From 2b3a887b20a543a3d37e47a57dcc621beb318a9c Mon Sep 17 00:00:00 2001 From: rsarm Date: Fri, 30 Aug 2024 11:32:24 +0200 Subject: [PATCH 1/2] Add custom tag prompt for manual triggering of image building --- .github/workflows/push-docker-image.yml | 27 ++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/push-docker-image.yml b/.github/workflows/push-docker-image.yml index b8de844..fc33c5f 100644 --- a/.github/workflows/push-docker-image.yml +++ b/.github/workflows/push-docker-image.yml @@ -2,8 +2,12 @@ name: Build and Push Docker Image on: release: - types: [created] - workflow_dispatch: # Allows manual triggering + types: [created, published] + workflow_dispatch: + inputs: + custom_tag: + description: 'Custom tag for manual trigger' + required: false jobs: build-and-push: @@ -17,6 +21,19 @@ jobs: APP_VERSION=$(grep appVersion chart/Chart.yaml | cut -d ' ' -f 2 | tr -d '"') echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV + - name: Determine release tag + run: | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + if [ -z "${{ github.event.inputs.custom_tag }}" ]; then + RELEASE_TAG="manual-trigger" + else + RELEASE_TAG="${{ github.event.inputs.custom_tag }}" + fi + else + RELEASE_TAG="${{ github.event.release.tag_name }}" + fi + echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV + - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: @@ -24,8 +41,8 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build Docker image - run: docker build -t ghcr.io/${{ github.repository_owner }}/f7t4jhub:${{ env.APP_VERSION }}-fcs${{ github.event.release.tag_name }} -f dockerfiles/Dockerfile . + - name: Build Docker image with combined tag + run: docker build -t ghcr.io/${{ github.repository_owner }}/f7t4jhub:${{ env.APP_VERSION }}-fcs${{ env.RELEASE_TAG }} -f dockerfiles/Dockerfile . - name: Push Docker image to GitHub Container Registry - run: docker push ghcr.io/${{ github.repository_owner }}/f7t4jhub:${{ env.APP_VERSION }}-fcs${{ github.event.release.tag_name }} + run: docker push ghcr.io/${{ github.repository_owner }}/f7t4jhub:${{ env.APP_VERSION }}-fcs${{ env.RELEASE_TAG }} From f235a2d3a3681b3e2e5bd9e05ca18e5eeafa0210 Mon Sep 17 00:00:00 2001 From: Rafael Sarmiento Date: Fri, 30 Aug 2024 11:35:23 +0200 Subject: [PATCH 2/2] .github/workflows/push-docker-image.yml --- .github/workflows/push-docker-image.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push-docker-image.yml b/.github/workflows/push-docker-image.yml index fc33c5f..eec8891 100644 --- a/.github/workflows/push-docker-image.yml +++ b/.github/workflows/push-docker-image.yml @@ -2,7 +2,7 @@ name: Build and Push Docker Image on: release: - types: [created, published] + types: [created] workflow_dispatch: inputs: custom_tag: @@ -42,7 +42,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build Docker image with combined tag - run: docker build -t ghcr.io/${{ github.repository_owner }}/f7t4jhub:${{ env.APP_VERSION }}-fcs${{ env.RELEASE_TAG }} -f dockerfiles/Dockerfile . + run: docker build -t ghcr.io/${{ github.repository_owner }}/f7t4jhub:${{ env.APP_VERSION }}-${{ env.RELEASE_TAG }} -f dockerfiles/Dockerfile . - name: Push Docker image to GitHub Container Registry - run: docker push ghcr.io/${{ github.repository_owner }}/f7t4jhub:${{ env.APP_VERSION }}-fcs${{ env.RELEASE_TAG }} + run: docker push ghcr.io/${{ github.repository_owner }}/f7t4jhub:${{ env.APP_VERSION }}-${{ env.RELEASE_TAG }}