Skip to content

Commit cbf1c5c

Browse files
Merge pull request #285 from microsoft/psl-refactor-docker-workflow
ci: Refactor Docker workflow
2 parents 268f922 + 25bd3d8 commit cbf1c5c

4 files changed

Lines changed: 21 additions & 25 deletions

File tree

.github/workflows/deploy-orchestrator.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ env:
6767

6868
jobs:
6969
docker-build:
70+
if: inputs.trigger_type == 'workflow_dispatch' && inputs.build_docker_image == true
7071
uses: ./.github/workflows/job-docker-build.yml
71-
with:
72-
trigger_type: ${{ inputs.trigger_type }}
73-
build_docker_image: ${{ inputs.build_docker_image }}
7472
secrets: inherit
7573

7674
deploy:

.github/workflows/job-deploy-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ jobs:
266266
# Set ACR name only when building Docker image
267267
if [[ "$BUILD_DOCKER_IMAGE" == "true" ]]; then
268268
# Extract ACR name from login server and set as environment variable
269-
ACR_NAME=$(echo "${{ secrets.ACR_TEST_LOGIN_SERVER }}")
269+
ACR_NAME=$(echo "${{ vars.ACR_TEST_LOGIN_SERVER }}")
270270
azd env set AZURE_ENV_CONTAINER_REGISTRY_ENDPOINT="$ACR_NAME"
271271
echo "Set ACR host to: $ACR_NAME"
272272
else

.github/workflows/job-deploy-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ jobs:
266266
267267
# Set ACR name only when building Docker image
268268
if ($env:BUILD_DOCKER_IMAGE -eq "true") {
269-
$ACR_NAME = "${{ secrets.ACR_TEST_LOGIN_SERVER }}"
269+
$ACR_NAME = "${{ vars.ACR_TEST_LOGIN_SERVER }}"
270270
azd env set AZURE_ENV_CONTAINER_REGISTRY_ENDPOINT="$ACR_NAME"
271271
Write-Host "Set ACR host to: $ACR_NAME"
272272
} else {

.github/workflows/job-docker-build.yml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
1-
name: Docker Build Job
1+
name: Build & Push Test Images (Feature Branch)
22

33
on:
44
workflow_call:
5-
inputs:
6-
trigger_type:
7-
description: 'Trigger type (workflow_dispatch, pull_request, schedule)'
8-
required: true
9-
type: string
10-
build_docker_image:
11-
description: 'Build And Push Docker Image (Optional)'
12-
required: false
13-
default: false
14-
type: boolean
155
outputs:
166
IMAGE_TAG:
177
description: "Generated Docker Image Tag"
188
value: ${{ jobs.docker-build.outputs.IMAGE_TAG }}
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
id-token: write
1914

2015
env:
2116
BRANCH_NAME: ${{ github.event.workflow_run.head_branch || github.head_ref || github.ref_name }}
2217

2318
jobs:
2419
docker-build:
25-
if: inputs.trigger_type == 'workflow_dispatch' && inputs.build_docker_image == true
2620
runs-on: ubuntu-latest
2721
environment: production
2822
outputs:
@@ -56,7 +50,11 @@ jobs:
5650
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
5751

5852
- name: Log in to Azure Container Registry
59-
run: az acr login --name ${{ secrets.ACR_TEST_LOGIN_SERVER }}
53+
shell: bash
54+
run: |
55+
# Extract registry name from login server (e.g., myacr.azurecr.io -> myacr)
56+
ACR_NAME=$(echo "${{ vars.ACR_TEST_LOGIN_SERVER }}" | cut -d'.' -f1)
57+
az acr login --name "$ACR_NAME"
6058
6159
- name: Build and Push Backend API Docker Image
6260
id: build_push_image
@@ -69,8 +67,8 @@ jobs:
6967
push: true
7068
provenance: false
7169
tags: |
72-
${{ secrets.ACR_TEST_LOGIN_SERVER }}/backend-api:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
73-
${{ secrets.ACR_TEST_LOGIN_SERVER }}/backend-api:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
70+
${{ vars.ACR_TEST_LOGIN_SERVER }}/backend-api:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
71+
${{ vars.ACR_TEST_LOGIN_SERVER }}/backend-api:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
7472
7573
- name: Build and Push Processor Docker Image
7674
uses: docker/build-push-action@v7
@@ -82,8 +80,8 @@ jobs:
8280
push: true
8381
provenance: false
8482
tags: |
85-
${{ secrets.ACR_TEST_LOGIN_SERVER }}/processor:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
86-
${{ secrets.ACR_TEST_LOGIN_SERVER }}/processor:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
83+
${{ vars.ACR_TEST_LOGIN_SERVER }}/processor:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
84+
${{ vars.ACR_TEST_LOGIN_SERVER }}/processor:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
8785
8886
- name: Build and Push Front End Docker Image
8987
uses: docker/build-push-action@v7
@@ -95,8 +93,8 @@ jobs:
9593
push: true
9694
provenance: false
9795
tags: |
98-
${{ secrets.ACR_TEST_LOGIN_SERVER }}/frontend:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
99-
${{ secrets.ACR_TEST_LOGIN_SERVER }}/frontend:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
96+
${{ vars.ACR_TEST_LOGIN_SERVER }}/frontend:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
97+
${{ vars.ACR_TEST_LOGIN_SERVER }}/frontend:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
10098
10199
- name: Verify Docker Image Build
102100
shell: bash
@@ -108,7 +106,7 @@ jobs:
108106
if: always()
109107
shell: bash
110108
run: |
111-
ACR_NAME=$(echo "${{ secrets.ACR_TEST_LOGIN_SERVER }}")
109+
ACR_NAME=$(echo "${{ vars.ACR_TEST_LOGIN_SERVER }}")
112110
echo "## 🐳 Docker Build Job Summary" >> $GITHUB_STEP_SUMMARY
113111
echo "" >> $GITHUB_STEP_SUMMARY
114112
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)