Skip to content

Commit a6c034e

Browse files
johnmathewsclaude
andcommitted
Build images once, push to both ghcr.io and ACR
- docker.yml: push to ACR after ghcr.io build (gated on AZURE_CREDENTIALS) - deploy.yml: trigger after docker.yml completes instead of building again - Removes duplicate image builds between workflows Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 460a331 commit a6c034e

2 files changed

Lines changed: 30 additions & 29 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
name: Deploy to AKS
22

33
on:
4-
push:
4+
workflow_run:
5+
workflows: ["Build and Push Docker Images"]
56
branches: [main]
6-
paths:
7-
- "src/**"
8-
- "k8s/**"
7+
types: [completed]
98
workflow_dispatch:
109

1110
concurrency:
1211
group: deploy-aks
1312
cancel-in-progress: false
1413

1514
jobs:
16-
ci:
17-
uses: ./.github/workflows/ci.yml
18-
19-
build-and-deploy:
20-
needs: ci
15+
deploy:
16+
if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success'
2117
runs-on: ubuntu-latest
2218
environment: production
2319

@@ -29,22 +25,6 @@ jobs:
2925
with:
3026
creds: ${{ secrets.AZURE_CREDENTIALS }}
3127

32-
- name: Build and push gateway image to ACR
33-
run: |
34-
az acr build \
35-
-r acrdocumentstream \
36-
-t gateway:${{ github.sha }} \
37-
-t gateway:latest \
38-
-f src/gateway/Dockerfile .
39-
40-
- name: Build and push worker image to ACR
41-
run: |
42-
az acr build \
43-
-r acrdocumentstream \
44-
-t worker:${{ github.sha }} \
45-
-t worker:latest \
46-
-f src/worker/Dockerfile .
47-
4828
- name: Set AKS context
4929
run: |
5030
az aks get-credentials \
@@ -57,20 +37,21 @@ jobs:
5737

5838
- name: Update deployment image tags
5939
run: |
40+
SHA=${{ github.event.workflow_run.head_sha || github.sha }}
6041
kubectl set image deployment/gateway \
61-
gateway=acrdocumentstream.azurecr.io/gateway:${{ github.sha }} \
42+
gateway=acrdocumentstream.azurecr.io/gateway:${SHA} \
6243
-n documentstream
6344
6445
kubectl set image deployment/extract-worker \
65-
extract-worker=acrdocumentstream.azurecr.io/worker:${{ github.sha }} \
46+
extract-worker=acrdocumentstream.azurecr.io/worker:${SHA} \
6647
-n documentstream
6748
6849
kubectl set image deployment/classify-worker \
69-
classify-worker=acrdocumentstream.azurecr.io/worker:${{ github.sha }} \
50+
classify-worker=acrdocumentstream.azurecr.io/worker:${SHA} \
7051
-n documentstream
7152
7253
kubectl set image deployment/store-worker \
73-
store-worker=acrdocumentstream.azurecr.io/worker:${{ github.sha }} \
54+
store-worker=acrdocumentstream.azurecr.io/worker:${SHA} \
7455
-n documentstream
7556
7657
- name: Wait for rollouts

.github/workflows/docker.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ jobs:
2727
username: ${{ github.actor }}
2828
password: ${{ secrets.GITHUB_TOKEN }}
2929

30+
- name: Log in to ACR
31+
if: secrets.AZURE_CREDENTIALS != ''
32+
uses: azure/login@v2
33+
with:
34+
creds: ${{ secrets.AZURE_CREDENTIALS }}
35+
36+
- name: Log in to ACR registry
37+
if: secrets.AZURE_CREDENTIALS != ''
38+
run: az acr login -n acrdocumentstream
39+
3040
- uses: docker/build-push-action@v6
3141
with:
3242
context: .
@@ -35,3 +45,13 @@ jobs:
3545
tags: |
3646
ghcr.io/johnmathews/documentstream-${{ matrix.image }}:latest
3747
ghcr.io/johnmathews/documentstream-${{ matrix.image }}:${{ github.sha }}
48+
49+
- name: Push to ACR
50+
if: secrets.AZURE_CREDENTIALS != ''
51+
run: |
52+
docker tag ghcr.io/johnmathews/documentstream-${{ matrix.image }}:${{ github.sha }} \
53+
acrdocumentstream.azurecr.io/${{ matrix.image }}:${{ github.sha }}
54+
docker tag ghcr.io/johnmathews/documentstream-${{ matrix.image }}:${{ github.sha }} \
55+
acrdocumentstream.azurecr.io/${{ matrix.image }}:latest
56+
docker push acrdocumentstream.azurecr.io/${{ matrix.image }}:${{ github.sha }}
57+
docker push acrdocumentstream.azurecr.io/${{ matrix.image }}:latest

0 commit comments

Comments
 (0)