Skip to content

Commit 822aa7f

Browse files
updated docker workflow to push the image of main branch to internal container registry
updated bicep to use the internal container registry
1 parent 3aeaf85 commit 822aa7f

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

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

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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 }}
@@ -46,7 +46,13 @@ jobs:
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+

infra/main.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ param AzureOpenAIStopSequence string = '\n'
166166
@description('Whether or not to stream responses from Azure OpenAI? True or False.')
167167
param AzureOpenAIStream bool = true
168168

169-
var WebAppImageName = 'DOCKER|acrbyocga.azurecr.io/webapp:latest'
169+
var WebAppImageName = 'DOCKER|byocgacontainerreg.azurecr.io/webapp:latest'
170170
var cosmosdb_database_name = 'db_conversation_history'
171171
var cosmosdb_container_name = 'conversations'
172172
var roleDefinitionId = '00000000-0000-0000-0000-000000000002'

infra/main.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,25 @@
55
"_generator": {
66
"name": "bicep",
77
"version": "0.33.93.31351",
8-
"templateHash": "896617532796464630"
8+
"templateHash": "7005910716688710298"
99
}
1010
},
1111
"parameters": {
12+
"environmentName": {
13+
"type": "string",
14+
"minLength": 3,
15+
"maxLength": 10,
16+
"metadata": {
17+
"description": "A unique prefix for all resources in this deployment. This should be 3-10 characters long:"
18+
}
19+
},
1220
"HostingPlanName": {
1321
"type": "string",
1422
"defaultValue": "[guid(resourceGroup().id)]",
1523
"metadata": {
24+
"azd": {
25+
"type": "location"
26+
},
1627
"description": "Name of App Service plan"
1728
}
1829
},
@@ -263,7 +274,7 @@
263274
}
264275
},
265276
"variables": {
266-
"WebAppImageName": "DOCKER|acrbyocga.azurecr.io/webapp:latest",
277+
"WebAppImageName": "DOCKER|byocgacontainerreg.azurecr.io/webapp:latest",
267278
"cosmosdb_database_name": "db_conversation_history",
268279
"cosmosdb_container_name": "conversations",
269280
"roleDefinitionId": "00000000-0000-0000-0000-000000000002",

0 commit comments

Comments
 (0)