Skip to content

Commit 448bac6

Browse files
added separate image tag based on branch
1 parent 9eae22b commit 448bac6

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
types: [closed]
66
branches:
77
- main
8+
- dev
9+
- demo
810
workflow_dispatch: # Add this line to enable manual triggering
911

1012
jobs:
@@ -26,7 +28,18 @@ jobs:
2628
username: ${{ secrets.ACR_USERNAME }}
2729
password: ${{ secrets.ACR_PASSWORD }}
2830

31+
- name: Set Docker image tag
32+
id: docker_tag
33+
run: |
34+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
35+
echo "TAG=latest" >> $GITHUB_ENV
36+
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
37+
echo "TAG=dev" >> $GITHUB_ENV
38+
elif [[ "${{ github.ref }}" == "refs/heads/demo" ]]; then
39+
echo "TAG=demo" >> $GITHUB_ENV
40+
fi
41+
2942
- name: Build and push Docker image
3043
run: |
31-
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/webapp:latest -f WebApp.Dockerfile .
32-
docker push ${{ secrets.ACR_LOGIN_SERVER }}/webapp:latest
44+
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ env.TAG }} -f WebApp.Dockerfile .
45+
docker push ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ env.TAG }}

0 commit comments

Comments
 (0)