Skip to content

Commit

Permalink
Use env var for whether docker should push or not
Browse files Browse the repository at this point in the history
  • Loading branch information
Insprill committed Apr 20, 2024
1 parent d6b434a commit 42ae055
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set Docker push status
run: echo "DOCKER_PUSH=${{ !env.ACT && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && github.event_name != 'pull_request' }}" >> $GITHUB_ENV

- name: Setup act
run: "sudo chown runner:docker /var/run/docker.sock"
if: ${{ env.ACT }}
Expand All @@ -25,14 +28,14 @@ jobs:

- name: Login to DockerHub
uses: docker/login-action@v3
if: ${{ !env.ACT && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && github.event_name != 'pull_request' }}
if: ${{ env.DOCKER_PUSH }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
if: $${{ !env.ACT && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && github.event_name != 'pull_request' }}
if: ${{ env.DOCKER_PUSH }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand All @@ -52,7 +55,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: . # Required for running with act
push: ${{ !env.ACT && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && github.event_name != 'pull_request' }}
push: ${{ env.DOCKER_PUSH }}
tags: ${{ env.DOCKER_IMAGE }}:${{ startsWith(github.ref, 'refs/tags/v') && 'latest' || 'develop' }}
platforms: ${{ env.DOCKER_PLATFORMS }}
cache-from: type=gha
Expand Down

0 comments on commit 42ae055

Please sign in to comment.