Skip to content

Commit

Permalink
Merge pull request #112 from microsoft/PSL-US-11557
Browse files Browse the repository at this point in the history
feat: Implementation of separate containers for Prod, Dev, and Demo Environments
  • Loading branch information
Roopan-Microsoft authored Dec 11, 2024
2 parents 9eae22b + 4f922e1 commit 3491d0c
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
types: [closed]
branches:
- main
- dev
- demo
workflow_dispatch: # Add this line to enable manual triggering

jobs:
Expand All @@ -20,13 +22,40 @@ jobs:
uses: docker/setup-buildx-action@v1

- name: Log in to Azure Container Registry
uses: azure/docker-login@v1
if: ${{ github.ref_name == 'main' }}
uses: azure/docker-login@v2
with:
login-server: ${{ secrets.ACR_LOGIN_SERVER }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}

- name: Log in to Azure Container Registry (Dev/Demo)
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' }}
uses: azure/docker-login@v2
with:
login-server: ${{ secrets.ACR_DEV_LOGIN_SERVER }}
username: ${{ secrets.ACR_DEV_USERNAME }}
password: ${{ secrets.ACR_DEV_PASSWORD }}

- name: Set Docker image tag
id: docker_tag
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "TAG=latest" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
echo "TAG=dev" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/demo" ]]; then
echo "TAG=demo" >> $GITHUB_ENV
fi
- name: Build and push Docker image
if: ${{ github.ref_name == 'main' }}
run: |
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ env.TAG }} -f WebApp.Dockerfile .
docker push ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ env.TAG }}
- name: Build and push Docker image (Dev/Demo)
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' }}
run: |
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/webapp:latest -f WebApp.Dockerfile .
docker push ${{ secrets.ACR_LOGIN_SERVER }}/webapp:latest
docker build -t ${{ secrets.ACR_DEV_LOGIN_SERVER }}/webapp:${{ env.TAG }} -f WebApp.Dockerfile .
docker push ${{ secrets.ACR_DEV_LOGIN_SERVER }}/webapp:${{ env.TAG }}

0 comments on commit 3491d0c

Please sign in to comment.