Skip to content

Commit 3491d0c

Browse files
Merge pull request #112 from microsoft/PSL-US-11557
feat: Implementation of separate containers for Prod, Dev, and Demo Environments
2 parents 9eae22b + 4f922e1 commit 3491d0c

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

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

Lines changed: 32 additions & 3 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:
@@ -20,13 +22,40 @@ jobs:
2022
uses: docker/setup-buildx-action@v1
2123

2224
- name: Log in to Azure Container Registry
23-
uses: azure/docker-login@v1
25+
if: ${{ github.ref_name == 'main' }}
26+
uses: azure/docker-login@v2
2427
with:
2528
login-server: ${{ secrets.ACR_LOGIN_SERVER }}
2629
username: ${{ secrets.ACR_USERNAME }}
2730
password: ${{ secrets.ACR_PASSWORD }}
2831

32+
- name: Log in to Azure Container Registry (Dev/Demo)
33+
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' }}
34+
uses: azure/docker-login@v2
35+
with:
36+
login-server: ${{ secrets.ACR_DEV_LOGIN_SERVER }}
37+
username: ${{ secrets.ACR_DEV_USERNAME }}
38+
password: ${{ secrets.ACR_DEV_PASSWORD }}
39+
40+
- name: Set Docker image tag
41+
id: docker_tag
42+
run: |
43+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
44+
echo "TAG=latest" >> $GITHUB_ENV
45+
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
46+
echo "TAG=dev" >> $GITHUB_ENV
47+
elif [[ "${{ github.ref }}" == "refs/heads/demo" ]]; then
48+
echo "TAG=demo" >> $GITHUB_ENV
49+
fi
50+
2951
- name: Build and push Docker image
52+
if: ${{ github.ref_name == 'main' }}
53+
run: |
54+
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' }}
3059
run: |
31-
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/webapp:latest -f WebApp.Dockerfile .
32-
docker push ${{ secrets.ACR_LOGIN_SERVER }}/webapp:latest
60+
docker build -t ${{ secrets.ACR_DEV_LOGIN_SERVER }}/webapp:${{ env.TAG }} -f WebApp.Dockerfile .
61+
docker push ${{ secrets.ACR_DEV_LOGIN_SERVER }}/webapp:${{ env.TAG }}

0 commit comments

Comments
 (0)