Skip to content

Commit aff5508

Browse files
committed
fix: align CI/CD scripts to Visio diagrams
1 parent 6db07a3 commit aff5508

File tree

5 files changed

+89
-95
lines changed

5 files changed

+89
-95
lines changed

.github/workflows/az_acr_push.yml

Lines changed: 11 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ on:
99
type: string
1010

1111
jobs:
12-
az-acr-push-dev:
13-
name: "DEV: ACR Build & Push"
12+
az-acr-push:
13+
name: "Docker: Build & Push"
1414
runs-on: ubuntu-latest
1515
environment: dev
16-
if: inputs.test_tag == 'false' && github.ref_name != 'prod'
1716
env:
18-
DOCKERFILE: ${{ vars.DOCKERFILE || 'Dockerfile' }}
1917
AZURE_CONTAINER_REGISTRY: ${{ vars.AZURE_CONTAINER_REGISTRY }}
2018
ACR_LOGIN_USERNAME: ${{ secrets.ACR_LOGIN_USERNAME }}
2119
ACR_LOGIN_PASSWORD: ${{ secrets.ACR_LOGIN_PASSWORD }}
@@ -26,7 +24,7 @@ jobs:
2624
- name: Checkout repository
2725
uses: actions/checkout@v4
2826
- name: Set up Docker Buildx
29-
uses: docker/setup-buildx-action@v3
27+
uses: docker/setup-buildx-action@v3
3028
- name: Log into registry
3129
uses: docker/login-action@v3
3230
with:
@@ -39,7 +37,7 @@ jobs:
3937
with:
4038
cache-from: type=gha
4139
cache-to: type=gha,mode=max
42-
file: ${{ env.DOCKERFILE }}
40+
file: 'Dockerfile'
4341
tags: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:${{ matrix.platform}}
4442
push: true
4543
build-args: platform=linux/${{ matrix.platform}}
@@ -49,71 +47,19 @@ jobs:
4947
uses: docker/build-push-action@v5
5048
with:
5149
push: true
52-
file: ${{ env.DOCKERFILE }}
50+
file: 'Dockerfile'
5351
tags: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:${{ matrix.platform}}-${{ github.ref_name }}
5452
cache-from: type=gha
5553
cache-to: type=gha,mode=max
5654
build-args: platform=linux/${{ matrix.platform}}
5755

58-
az-acr-push-test:
59-
name: "TEST: ACR Build & Push"
60-
runs-on: ubuntu-latest
61-
environment: dev
62-
if: inputs.test_tag == 'true'
63-
env:
64-
DOCKERFILE: dev.Dockerfile
65-
AZURE_CONTAINER_REGISTRY: ${{ vars.AZURE_CONTAINER_REGISTRY }}
66-
ACR_LOGIN_USERNAME: ${{ secrets.ACR_LOGIN_USERNAME }}
67-
ACR_LOGIN_PASSWORD: ${{ secrets.ACR_LOGIN_PASSWORD }}
68-
steps:
69-
- name: Checkout repository
70-
uses: actions/checkout@v4
71-
- name: Set up Docker Buildx
72-
uses: docker/setup-buildx-action@v3
73-
- name: Log into registry
74-
uses: docker/login-action@v3
75-
with:
76-
registry: "${{ env.AZURE_CONTAINER_REGISTRY }}"
77-
username: "${{ env.ACR_LOGIN_USERNAME }}"
78-
password: "${{ env.ACR_LOGIN_PASSWORD }}"
79-
80-
- name: Build & Push
56+
- name: Build & Push - GPU
57+
if: ${{ github.ref == github.repository.default_branch && hashFiles('gpu.Dockerflie') != '' }}
8158
uses: docker/build-push-action@v5
8259
with:
60+
push: true
61+
file: 'gpu.Dockerfile'
62+
tags: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:${{ matrix.platform}}-gpu
8363
cache-from: type=gha
8464
cache-to: type=gha,mode=max
85-
file: ${{ env.DOCKERFILE }}
86-
tags: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:test
87-
push: true
88-
build-args: platform=linux/amd64
89-
90-
az-acr-push-prod:
91-
name: "PROD: ACR Build & Push"
92-
runs-on: ubuntu-latest
93-
environment: ${{ github.ref_name }}
94-
if: github.ref_name == 'prod'
95-
env:
96-
DOCKERFILE: Dockerfile
97-
AZURE_CONTAINER_REGISTRY: ${{ vars.AZURE_CONTAINER_REGISTRY }}
98-
ACR_LOGIN_USERNAME: ${{ secrets.ACR_LOGIN_USERNAME }}
99-
ACR_LOGIN_PASSWORD: ${{ secrets.ACR_LOGIN_PASSWORD }}
100-
steps:
101-
- name: Checkout repository
102-
uses: actions/checkout@v4
103-
- name: Set up Docker Buildx
104-
uses: docker/setup-buildx-action@v3
105-
- name: Log into registry
106-
uses: docker/login-action@v3
107-
with:
108-
registry: "${{ env.AZURE_CONTAINER_REGISTRY }}"
109-
username: "${{ env.ACR_LOGIN_USERNAME }}"
110-
password: "${{ env.ACR_LOGIN_PASSWORD }}"
111-
112-
- name: Build & Push
113-
uses: docker/build-push-action@v5
114-
with:
115-
push: true
116-
file: ${{ env.DOCKERFILE }}
117-
tags: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:version-tag
118-
build-args: platform=linux/amd64
119-
65+
build-args: platform=linux/${{ matrix.platform}}

.github/workflows/k8s_deploy.yml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,42 @@ permissions:
1010
actions: read
1111

1212
jobs:
13+
az-acr-push:
14+
name: "Docker: Build & Push"
15+
runs-on: ubuntu-latest
16+
environment: prod
17+
env:
18+
DOCKERFILE: ${{ vars.DOCKERFILE }}
19+
AZURE_CONTAINER_REGISTRY: ${{ vars.AZURE_CONTAINER_REGISTRY }}
20+
ACR_LOGIN_USERNAME: ${{ secrets.ACR_LOGIN_USERNAME }}
21+
ACR_LOGIN_PASSWORD: ${{ secrets.ACR_LOGIN_PASSWORD }}
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
- name: Log into registry
28+
uses: docker/login-action@v3
29+
with:
30+
registry: "${{ env.AZURE_CONTAINER_REGISTRY }}"
31+
username: "${{ env.ACR_LOGIN_USERNAME }}"
32+
password: "${{ env.ACR_LOGIN_PASSWORD }}"
33+
34+
- name: Build & Push
35+
uses: docker/build-push-action@v5
36+
with:
37+
cache-from: type=gha
38+
cache-to: type=gha,mode=max
39+
file: ${{ env.DOCKERFILE }}
40+
tags: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:v${{ github.event.release.tag_name }}
41+
push: true
42+
build-args: platform=linux/amd64
43+
1344
k8-deploy:
1445
name: 'K8: Deploy'
1546
runs-on: ubuntu-latest
16-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
17-
environment: ${{ github.ref_name }}
47+
needs: [az-acr-push]
48+
environment: prod
1849
env:
1950
KUBELOGIN_VERSION: "v0.0.25"
2051
KUBERNETES_CLUSTER_REPO_NAME: "${{ vars.KUBERNETES_CLUSTER_REPO_NAME }}"
@@ -63,7 +94,7 @@ jobs:
6394
namespace: ${{ env.KUBERNETES_NAMESPACE }}
6495
manifests: apply.yml
6596
pull-images: false
66-
images: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:amd64
97+
images: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:v${{ github.event.release.tag_name }}
6798
strategy: canary
6899
action: deploy
69100
percentage: 20
@@ -75,7 +106,7 @@ jobs:
75106
namespace: ${{ env.KUBERNETES_NAMESPACE }}
76107
manifests: apply.yml
77108
pull-images: false
78-
images: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:amd64
109+
images: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:v${{ github.event.release.tag_name }}
79110
strategy: canary
80111
action: promote
81112

@@ -86,6 +117,6 @@ jobs:
86117
namespace: ${{ env.KUBERNETES_NAMESPACE }}
87118
manifests: apply.yml
88119
pull-images: false
89-
images: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:amd64
120+
images: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:v${{ github.event.release.tag_name }}
90121
strategy: canary
91122
action: reject

.github/workflows/k8s_test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,40 @@ permissions:
1515
actions: read
1616

1717
jobs:
18+
az-acr-push:
19+
name: "Docker: Build & Push"
20+
runs-on: ubuntu-latest
21+
environment: dev
22+
env:
23+
AZURE_CONTAINER_REGISTRY: ${{ vars.AZURE_CONTAINER_REGISTRY }}
24+
ACR_LOGIN_USERNAME: ${{ secrets.ACR_LOGIN_USERNAME }}
25+
ACR_LOGIN_PASSWORD: ${{ secrets.ACR_LOGIN_PASSWORD }}
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
- name: Log into registry
32+
uses: docker/login-action@v3
33+
with:
34+
registry: "${{ env.AZURE_CONTAINER_REGISTRY }}"
35+
username: "${{ env.ACR_LOGIN_USERNAME }}"
36+
password: "${{ env.ACR_LOGIN_PASSWORD }}"
37+
38+
- name: Build & Push
39+
uses: docker/build-push-action@v5
40+
with:
41+
cache-from: type=gha
42+
cache-to: type=gha,mode=max
43+
file: 'dev.Dockerfile'
44+
tags: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:test-${{ github.head_ref }}
45+
push: true
46+
build-args: platform=linux/amd64
47+
1848
k8-test:
1949
name: 'K8: Test'
2050
runs-on: ubuntu-latest
51+
needs: [az-acr-push]
2152
environment: dev
2253
env:
2354
KUBELOGIN_VERSION: "v0.0.25"
@@ -64,5 +95,6 @@ jobs:
6495
bash cicd-deployment-scripts/k8s/test.sh \
6596
-n ${{ env.KUBERNETES_NAMESPACE }} \
6697
-d ${{ github.event.repository.name }} \
98+
-h ${{ github.head_ref }} \
6799
-r ${{ env.AZURE_CONTAINER_REGISTRY }} \
68100
-t ${{ inputs.test_cmd }}

.github/workflows/py_release.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

k8s/test.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,38 @@ set -e
33

44
KUBERNETES_NAMESPACE=""
55
KUBERNETES_DEPLOYMENT_NAME=""
6+
GITHUB_HEAD_REF=""
67
AZURE_CONTAINER_REGISTRY=""
78
TEST_CMD=""
89

9-
while getopts n:d:r:t: flag
10+
while getopts n:d:h:r:t: flag
1011
do
1112
case "${flag}" in
1213
n) KUBERNETES_NAMESPACE=${OPTARG};;
1314
d) KUBERNETES_DEPLOYMENT_NAME=${OPTARG};;
15+
h) GITHUB_HEAD_REF=${OPTARG};;
1416
r) AZURE_CONTAINER_REGISTRY=${OPTARG};;
1517
t) TEST_CMD=${OPTARG};;
1618
esac
1719
done
1820

21+
KUBERNETES_POD_EXISTING_IMAGE=$(kubectl get pod --output json \
22+
--selector app=${KUBERNETES_DEPLOYMENT_NAME} \
23+
| jq -r '.items[] | .spec.containers[0].image')
1924
KUBERNETES_POD_NAME=$(kubectl get pod --output json \
2025
--selector app=${KUBERNETES_DEPLOYMENT_NAME} \
2126
| jq -r '.items[] | .metadata.name')
22-
KUBERNETES_POD_IMAGE=$(kubectl get pod --output json \
23-
--selector app=${KUBERNETES_DEPLOYMENT_NAME} \
24-
| jq -r '.items[] | .spec.containers[0].image')
2527

26-
kubectl set image deployment/${KUBERNETES_DEPLOYMENT_NAME} ${KUBERNETES_DEPLOYMENT_NAME}=${AZURE_CONTAINER_REGISTRY}/${KUBERNETES_DEPLOYMENT_NAME}:test
27-
echo "::warning::using ${AZURE_CONTAINER_REGISTRY}/${KUBERNETES_DEPLOYMENT_NAME}:test"
28+
kubectl set image deployment/${KUBERNETES_DEPLOYMENT_NAME} ${KUBERNETES_DEPLOYMENT_NAME}=${AZURE_CONTAINER_REGISTRY}/${KUBERNETES_DEPLOYMENT_NAME}:test-${GITHUB_HEAD_REF}
29+
echo "::warning::using ${AZURE_CONTAINER_REGISTRY}/${KUBERNETES_DEPLOYMENT_NAME}:test-${GITHUB_HEAD_REF}"
2830

2931
set +e
3032
exitcode=0
3133
kubectl exec -it $KUBERNETES_POD_NAME -- $TEST_CMD
3234
exitcode=$?
3335
set -e
3436

35-
kubectl set image deployment/${KUBERNETES_DEPLOYMENT_NAME} ${KUBERNETES_DEPLOYMENT_NAME}=${KUBERNETES_POD_IMAGE}
36-
echo "::notice::using ${KUBERNETES_POD_IMAGE}"
37+
kubectl set image deployment/${KUBERNETES_DEPLOYMENT_NAME} ${KUBERNETES_DEPLOYMENT_NAME}=${KUBERNETES_POD_EXISTING_IMAGE}
38+
echo "::notice::using ${KUBERNETES_POD_EXISTING_IMAGE}"
3739

3840
exit $exitcode

0 commit comments

Comments
 (0)