Skip to content

Commit

Permalink
Always try to build the docker container but only push if merging to …
Browse files Browse the repository at this point in the history
…main.
  • Loading branch information
silverl committed Nov 14, 2024
1 parent 2d28495 commit dd9a89d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ jobs:
with:
images: trackabout/snappass

- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_KEY }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

Expand All @@ -48,12 +41,19 @@ jobs:
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to Docker Hub
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_KEY }}

- name: Build container image, publish if not a PR
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
cache-from: type=gha,scope=${{ github.repository }}
cache-to: type=gha,mode=max,scope=${{ github.repository }}

0 comments on commit dd9a89d

Please sign in to comment.