-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (110 loc) · 3.77 KB
/
build-images.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Create and publish Docker images
on:
push:
branches:
- main
# tags:
# - 'v*'
env:
REGISTRY: rtwcr1.azurecr.io
REGISTRY_USERNAME: GitHub-Action
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
service: [frontend, services/auth-service, services/analytics-service, services/heatmap-service, services/pin-service, services/update-service]
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Filter changes
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
service:
- '${{ matrix.service }}/version.txt'
- name: Set version environment variable
if: steps.changes.outputs.service == 'true'
run: |
VER=$(cat ${{ matrix.service }}/version.txt)
echo "VERSION=$VER" >> $GITHUB_ENV
- name: Log in to the Container registry
if: steps.changes.outputs.service == 'true'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ env.REGISTRY_PASSWORD }}
- name: Build and push Docker image (${{ matrix.service }})
if: steps.changes.outputs.service == 'true'
uses: docker/build-push-action@v5
with:
context: ${{ matrix.service }}
push: true
tags: |
${{ env.REGISTRY }}/${{ matrix.service }}:latest
${{ env.REGISTRY }}/${{ matrix.service }}:${{ env.VERSION }}
apply-images-service:
runs-on: self-hosted
strategy:
fail-fast: false
matrix:
service: [auth-service, analytics-service, heatmap-service, pin-service, update-service]
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Filter changes
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
service:
- 'service/${{ matrix.service }}/version.txt'
- name: Azure login
uses: azure/login@v1
with:
auth-type: IDENTITY
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Kubernetes deploy new images
working-directory: deployement/k8s
run: |
az aks get-credentials --resource-group ${{ secrets.AKS_RESOURCE_GROUP_NAME }} --name ${{ secrets.KUBERNETES_CLUSTER_NAME }}
kubectl rollout restart deployment ${{ matrix.service }}
apply-images-frontend:
runs-on: self-hosted
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Filter changes
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
service:
- 'frontend/version.txt'
- name: Azure login
uses: azure/login@v1
with:
auth-type: IDENTITY
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Kubernetes deploy new images
working-directory: deployement/k8s
run: |
az aks get-credentials --resource-group ${{ secrets.AKS_RESOURCE_GROUP_NAME }} --name ${{ secrets.KUBERNETES_CLUSTER_NAME }}
ls | grep "frontend" | xargs -L 1 -d '\n' basename -s '.yaml' | xargs -L 1 -d '\n' kubectl rollout restart deployment