Skip to content

Commit af9ca25

Browse files
author
Oleksandr Dzhychko
committed
build: only attempt to log in into docker when attempting to push to docker
1 parent 1350cf7 commit af9ca25

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

.github/workflows/publish.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ jobs:
1717
permissions:
1818
contents: read
1919
packages: write
20+
env:
21+
# We only push the resulting image when we are on release tag (i.e., the only time we have a push event) or on
22+
# manual request via the workflow_dispatch event.
23+
PUSH: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' }}
2024
steps:
2125
- uses: actions/checkout@v4
2226
- uses: actions/setup-node@v4
@@ -96,6 +100,8 @@ jobs:
96100
IS_PR: ${{ github.event_name == 'pull_request' }}
97101
# Try to log in early. If this fails, there's no reason to perform the remaining steps
98102
- name: Log in to Docker Hub
103+
# Only attempt to log in if we later attempt to push.
104+
if: ${{ env.PUSH }}
99105
uses: docker/login-action@v3
100106
with:
101107
username: ${{ secrets.DOCKER_HUB_USER }}
@@ -108,10 +114,6 @@ jobs:
108114
platforms: linux/amd64,linux/arm64
109115
- name: Build and publish model-server Docker image
110116
uses: docker/build-push-action@v6
111-
env:
112-
# We only push the resulting image when we are on release tag (i.e., the only time we have a push event) or on
113-
# manual request via the workflow_dispatch event.
114-
PUSH: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' }}
115117
with:
116118
context: ./model-server
117119
file: ./model-server/Dockerfile

0 commit comments

Comments
 (0)