Skip to content

Commit f151230

Browse files
committed
ci: gate docker push via env vars
1 parent b2ee12d commit f151230

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ jobs:
206206
runs-on: ubuntu-latest
207207
needs: [test, integration-test]
208208
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
209+
env:
210+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
211+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
209212

210213
steps:
211214
- uses: actions/checkout@v4
@@ -222,7 +225,7 @@ jobs:
222225
fi
223226
224227
- name: Login to Docker Hub
225-
if: ${{ secrets.DOCKER_USERNAME != '' && secrets.DOCKER_PASSWORD != '' }}
228+
if: ${{ env.DOCKER_USERNAME != '' && env.DOCKER_PASSWORD != '' }}
226229
uses: docker/login-action@v2
227230
with:
228231
username: ${{ secrets.DOCKER_USERNAME }}
@@ -241,7 +244,7 @@ jobs:
241244
type=raw,value=latest,enable={{is_default_branch}}
242245
243246
- name: Build and push Docker image
244-
if: ${{ secrets.DOCKER_USERNAME != '' && secrets.DOCKER_PASSWORD != '' }}
247+
if: ${{ env.DOCKER_USERNAME != '' && env.DOCKER_PASSWORD != '' }}
245248
uses: docker/build-push-action@v4
246249
with:
247250
context: .

0 commit comments

Comments
 (0)