From 1ed9f4c75cf24e03ca8e11e7bfa1cc49943f3f8c Mon Sep 17 00:00:00 2001 From: Yiorgos Marinellis Date: Wed, 21 May 2025 13:10:53 +0300 Subject: [PATCH 1/3] Add workflow to build image for branch and latest for master --- .github/workflows/docker-image.yml | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..29d7a26 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,49 @@ +name: Docker Image CI + +on: + push: + branches: [ main ] + pull_request: + workflow_dispatch: + inputs: + branch: + description: 'Branch to run the workflow on' + required: false + tags: + - "v*.*.*" # Runs on version tags + + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Saves time by not fetching other branches + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + id: docker_build + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: | + ghcr.io/${{ github.repository }}:${{ github.ref_name }} + ${{ github.ref_name == 'main' && format('ghcr.io/{0}:latest', github.repository) || '' }} + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file From 33bc0e33084c18f5b1e4027e25c984341a86a41d Mon Sep 17 00:00:00 2001 From: Yiorgos Marinellis Date: Wed, 21 May 2025 13:15:24 +0300 Subject: [PATCH 2/3] Replace invalid value 'tags' with 'release' --- .github/workflows/docker-image.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 29d7a26..0c2c1cb 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -9,8 +9,9 @@ on: branch: description: 'Branch to run the workflow on' required: false - tags: - - "v*.*.*" # Runs on version tags + release: + types: + - created jobs: From 3a3cf05c20393b0246e510e52a6438112a49be2d Mon Sep 17 00:00:00 2001 From: Yiorgos Marinellis Date: Wed, 21 May 2025 13:16:49 +0300 Subject: [PATCH 3/3] Remove build on pull request --- .github/workflows/docker-image.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0c2c1cb..514a680 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -3,7 +3,6 @@ name: Docker Image CI on: push: branches: [ main ] - pull_request: workflow_dispatch: inputs: branch: