Skip to content

Commit 396cbab

Browse files
committed
fix docker build
1 parent c488255 commit 396cbab

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

.github/workflows/docker.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12+
env:
13+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME || '' }}
14+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN || '' }}
15+
IMAGE_NAME: docai-toolkit
1216
steps:
1317
- name: Checkout
1418
uses: actions/checkout@v4
@@ -17,15 +21,15 @@ jobs:
1721
uses: docker/setup-buildx-action@v3
1822

1923
- name: Login to DockerHub
20-
if: secrets.DOCKERHUB_USERNAME && secrets.DOCKERHUB_TOKEN
24+
if: env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != ''
2125
uses: docker/login-action@v3
2226
with:
23-
username: ${{ secrets.DOCKERHUB_USERNAME }}
24-
password: ${{ secrets.DOCKERHUB_TOKEN }}
27+
username: ${{ env.DOCKERHUB_USERNAME }}
28+
password: ${{ env.DOCKERHUB_TOKEN }}
2529

2630
- name: Build image
2731
uses: docker/build-push-action@v6
2832
with:
2933
context: .
30-
push: ${{ secrets.DOCKERHUB_USERNAME && secrets.DOCKERHUB_TOKEN }}
31-
tags: ${{ secrets.DOCKERHUB_USERNAME }}/docai-toolkit:latest
34+
push: ${{ env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != '' }}
35+
tags: ${{ (env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != '') && format('{0}/{1}:latest', env.DOCKERHUB_USERNAME, env.IMAGE_NAME) || format('{0}:latest', env.IMAGE_NAME) }}

0 commit comments

Comments
 (0)