Skip to content

Commit 8bd4e47

Browse files
refactor: Replace secrets with vars for ACR name in Docker workflows
1 parent 3f193ba commit 8bd4e47

4 files changed

Lines changed: 23 additions & 27 deletions

File tree

.github/workflows/deploy-orchestrator.yml

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

7373
jobs:
7474
docker-build:
75+
if: inputs.trigger_type == 'workflow_dispatch' && inputs.build_docker_image == true
7576
uses: ./.github/workflows/job-docker-build.yml
76-
with:
77-
trigger_type: ${{ inputs.trigger_type }}
78-
build_docker_image: ${{ inputs.build_docker_image }}
7977
secrets: inherit
8078

8179
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
azd env set AZURE_ENV_IMAGETAG="$IMAGE_TAG"
267267
268268
if [[ "$BUILD_DOCKER_IMAGE" == "true" ]]; then
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 name 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
@@ -265,7 +265,7 @@ jobs:
265265
# Set ACR name only when building Docker image
266266
if ($env:BUILD_DOCKER_IMAGE -eq "true") {
267267
# Extract ACR name from login server and set as environment variable
268-
$ACR_NAME = "${{ secrets.ACR_TEST_LOGIN_SERVER }}"
268+
$ACR_NAME = "${{ vars.ACR_TEST_LOGIN_SERVER }}"
269269
azd env set AZURE_ENV_CONTAINER_REGISTRY_ENDPOINT="$ACR_NAME"
270270
Write-Host "Set ACR name to: $ACR_NAME"
271271
} else {

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

Lines changed: 20 additions & 22 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 ContentProcessor Docker image
6260
uses: docker/build-push-action@v7
@@ -67,8 +65,8 @@ jobs:
6765
file: ./src/ContentProcessor/Dockerfile
6866
push: true
6967
tags: |
70-
${{ secrets.ACR_TEST_LOGIN_SERVER }}/contentprocessor:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
71-
${{ secrets.ACR_TEST_LOGIN_SERVER }}/contentprocessor:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
68+
${{ vars.ACR_TEST_LOGIN_SERVER }}/contentprocessor:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
69+
${{ vars.ACR_TEST_LOGIN_SERVER }}/contentprocessor:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
7270
7371
- name: Build and Push ContentProcessorAPI Docker image
7472
uses: docker/build-push-action@v7
@@ -79,8 +77,8 @@ jobs:
7977
file: ./src/ContentProcessorAPI/Dockerfile
8078
push: true
8179
tags: |
82-
${{ secrets.ACR_TEST_LOGIN_SERVER }}/contentprocessorapi:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
83-
${{ secrets.ACR_TEST_LOGIN_SERVER }}/contentprocessorapi:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
80+
${{ vars.ACR_TEST_LOGIN_SERVER }}/contentprocessorapi:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
81+
${{ vars.ACR_TEST_LOGIN_SERVER }}/contentprocessorapi:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
8482
8583
- name: Build and Push ContentProcessorWeb Docker image
8684
uses: docker/build-push-action@v7
@@ -91,8 +89,8 @@ jobs:
9189
file: ./src/ContentProcessorWeb/Dockerfile
9290
push: true
9391
tags: |
94-
${{ secrets.ACR_TEST_LOGIN_SERVER }}/contentprocessorweb:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
95-
${{ secrets.ACR_TEST_LOGIN_SERVER }}/contentprocessorweb:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
92+
${{ vars.ACR_TEST_LOGIN_SERVER }}/contentprocessorweb:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
93+
${{ vars.ACR_TEST_LOGIN_SERVER }}/contentprocessorweb:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
9694
9795
- name: Build and Push ContentProcessorWorkflow Docker image
9896
uses: docker/build-push-action@v6
@@ -103,8 +101,8 @@ jobs:
103101
file: ./src/ContentProcessorWorkflow/Dockerfile
104102
push: true
105103
tags: |
106-
${{ secrets.ACR_TEST_LOGIN_SERVER }}/contentprocessorworkflow:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
107-
${{ secrets.ACR_TEST_LOGIN_SERVER }}/contentprocessorworkflow:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
104+
${{ vars.ACR_TEST_LOGIN_SERVER }}/contentprocessorworkflow:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}
105+
${{ vars.ACR_TEST_LOGIN_SERVER }}/contentprocessorworkflow:${{ steps.generate_docker_tag.outputs.IMAGE_TAG }}_${{ github.run_number }}
108106
109107
- name: Verify Docker Image Build
110108
shell: bash
@@ -116,7 +114,7 @@ jobs:
116114
if: always()
117115
shell: bash
118116
run: |
119-
ACR_NAME=$(echo "${{ secrets.ACR_TEST_LOGIN_SERVER }}")
117+
ACR_NAME=$(echo "${{ vars.ACR_TEST_LOGIN_SERVER }}")
120118
echo "## 🐳 Docker Build Job Summary" >> $GITHUB_STEP_SUMMARY
121119
echo "" >> $GITHUB_STEP_SUMMARY
122120
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)