Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom tag prompt for manual triggering of image building #32

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions .github/workflows/push-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ name: Build and Push Docker Image
on:
release:
types: [created]
workflow_dispatch: # Allows manual triggering
workflow_dispatch:
inputs:
custom_tag:
description: 'Custom tag for manual trigger'
required: false

jobs:
build-and-push:
Expand All @@ -17,15 +21,28 @@ 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:
registry: ghcr.io
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 }}-${{ 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 }}-${{ env.RELEASE_TAG }}
Loading