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 bcaa725
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on: [ push, pull_request ]
env:
DOCKER_IMAGE: insprill/intellectual
DOCKER_PLATFORMS: linux/amd64,linux/arm64
DOCKER_PUSH: ${{ !env.ACT && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) && github.event_name != 'pull_request' }}

jobs:
build-docker:
Expand All @@ -25,14 +26,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 +53,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 bcaa725

Please sign in to comment.