@@ -24,16 +24,16 @@ jobs:
2424 - name : Set up Docker Buildx
2525 uses : docker/setup-buildx-action@v1
2626
27- - name : Log in to Azure Container Registry
27+ - name : Log in to Azure Container Registry - External Registry
2828 if : ${{ github.ref_name == 'main' }}
2929 uses : azure/docker-login@v2
3030 with :
3131 login-server : ${{ secrets.ACR_LOGIN_SERVER }}
3232 username : ${{ secrets.ACR_USERNAME }}
3333 password : ${{ secrets.ACR_PASSWORD }}
3434
35- - name : Log in to Azure Container Registry (Dev/Demo/Dependabotchanges)
36- if : ${{ github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }}
35+ - name : Log in to Azure Container Registry (Main/ Dev/Demo/Dependabotchanges) - Internal Registry
36+ if : ${{ github.ref_name == 'main' ||github.ref_name == ' dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }}
3737 uses : azure/docker-login@v2
3838 with :
3939 login-server : ${{ secrets.ACR_DEV_LOGIN_SERVER }}
4646
4747 - name : Get registry
4848 id : registry
49- run : echo "registry=${{ github.ref_name == 'main' && secrets.ACR_LOGIN_SERVER || secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT
49+ run : |
50+ if [[ "${{ github.ref_name }}" == "main" ]]; then
51+ echo "ext_registry=${{ secrets.ACR_LOGIN_SERVER }}" >> $GITHUB_OUTPUT
52+ echo "int_registry=${{ secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT
53+ else
54+ echo "int_registry=${{ secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT
55+ fi
5056
5157 - name : Determine Tag Name Based on Branch
5258 id : determine_tag
@@ -61,15 +67,26 @@ jobs:
6167 echo "tagname=dependabotchanges" >> $GITHUB_OUTPUT
6268 else
6369 echo "tagname=default" >> $GITHUB_OUTPUT
64-
6570 fi
6671
67- - name : Build Docker Image and optionally push
72+ - name : Build Docker Image and optionally push - Internal Registry
6873 uses : docker/build-push-action@v6
6974 with :
7075 context : .
7176 file : WebApp.Dockerfile
7277 push : ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'dependabotchanges' }}
7378 tags : |
74- ${{ steps.registry.outputs.registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}
75- ${{ steps.registry.outputs.registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
79+ ${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}
80+ ${{ steps.registry.outputs.int_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
81+
82+ - name : Build Docker Image and optionally push - External Registry
83+ if : ${{ github.ref_name == 'main' }}
84+ uses : docker/build-push-action@v6
85+ with :
86+ context : .
87+ file : WebApp.Dockerfile
88+ push : ${{github.ref_name == 'main' }}
89+ tags : |
90+ ${{ steps.registry.outputs.ext_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}
91+ ${{ steps.registry.outputs.ext_registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
92+
0 commit comments