Skip to content

Commit 307f712

Browse files
Update docker-build-and-push.yml
1 parent cb414c8 commit 307f712

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

.github/workflows/docker-build-and-push.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,16 @@ jobs:
4646
echo "TAG=dev" >> $GITHUB_ENV
4747
elif [[ "${{ github.ref }}" == "refs/heads/demo" ]]; then
4848
echo "TAG=demo" >> $GITHUB_ENV
49+
else
50+
echo "TAG=github.ref_name" >> $GITHUB_ENV
4951
fi
5052
51-
- name: Build and push Docker image
52-
if: ${{ github.ref_name == 'main' }}
53+
- name: Build and push Docker image optionally
5354
run: |
5455
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ env.TAG }} -f WebApp.Dockerfile .
55-
docker push ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ env.TAG }}
56-
57-
- name: Build and push Docker image (Dev/Demo)
58-
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' }}
59-
run: |
60-
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/webapp:latest -f WebApp.Dockerfile .
61-
docker push ${{ secrets.ACR_LOGIN_SERVER }}/webapp:latest
56+
if [[ "${{ env.TAG }}" == "latest" || "${{ env.TAG }}" == "dev" || "${{ env.TAG }}" == "demo" ]]; then
57+
docker push ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ env.TAG }}
58+
else
59+
echo "Skipping Docker push for tag: ${{ env.TAG }}"
60+
fi
6261

0 commit comments

Comments
 (0)