From 1852133a7d38142a09b7852e1aa2dbbd397a6f20 Mon Sep 17 00:00:00 2001 From: rsarm Date: Wed, 29 May 2024 12:48:52 +0200 Subject: [PATCH] Create push-docker-image.yml --- .github/workflows/push-docker-image.yml | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/push-docker-image.yml diff --git a/.github/workflows/push-docker-image.yml b/.github/workflows/push-docker-image.yml new file mode 100644 index 0000000..4d4e55e --- /dev/null +++ b/.github/workflows/push-docker-image.yml @@ -0,0 +1,32 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + workflow_dispatch: # Allows manual triggering + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Get version from Chart.yaml + run: | + APP_VERSION=$(grep appVersion chart/Chart.yaml | cut -d ' ' -f 2 | tr -d '"') + echo "::set-env name=APP_VERSION::$APP_VERSION" + + - 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 }}/${{ github.repository_name }}:${{ env.APP_VERSION }} -f dockerfiles/Dockerfile . + + - name: Push Docker image to GitHub Container Registry + run: docker push ghcr.io/${{ github.repository_owner }}/${{ github.repository_name }}:${{ env.APP_VERSION }}