generated from FINTLabs/fint-flyt-instance-gateway-template
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (117 loc) · 3.6 KB
/
md.yaml
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
name: MD
on:
workflow_dispatch:
inputs:
cluster:
description: 'Select environment'
required: true
default: 'warning'
type: choice
options:
- aks-alpha-fint-2021-11-18
- aks-beta-fint-2021-11-23
- aks-api-fint-2022-02-08
org:
description: 'Select organisation'
required: true
default: 'warning'
type: choice
options:
- fintlabs-no
- ofk-no
- bfk-no
- afk-no
- tromsfylke-no
- vlfk-no
- rogfk-no
- innlandetfylke-no
- agderfk-no
- mrfylke-no
- vestfoldfylke-no
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
CLUSTER_NAME: ${{ inputs.cluster }}
ORG: ${{ inputs.org }}
jobs:
cd:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/github-script@v7
name: Get resource group name
id: rg
with:
script: |
const a = '${{ inputs.cluster }}'.split('-')
return `rg-${a[0]}-${a[1]}`
result-encoding: string
- uses: actions/github-script@v7
name: Get environment
id: environment
with:
script: |
const a = '${{ inputs.cluster }}'.split('-')
return `${a[1]}`
result-encoding: string
- uses: actions/github-script@v7
name: Get auth
id: auth
with:
script: |
const e = '${{ steps.environment.outputs.result }}'.toUpperCase()
return `secrets.AKS_${e}_FINT_GITHUB`
result-encoding: string
- run: |
echo "Cluster: $CLUSTER_NAME"
echo "Resource group: ${{ steps.rg.outputs.result }}"
echo "Environment: ${{ steps.environment.outputs.result }}"
echo "OrgId: $ORG"
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,enable=true,priority=100,prefix=sha-,suffix=,format=short
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Bake manifests with Kustomize
uses: azure/k8s-bake@v3
with:
renderEngine: 'kustomize'
kustomizationPath: 'kustomize/overlays/${{ env.ORG}}/${{ steps.environment.outputs.result }}'
id: bake
- uses: azure/login@v2
with:
creds: "${{ secrets[format('AKS_{0}_FINT_GITHUB', steps.environment.outputs.result)] }}"
- name: Set the target cluster
uses: azure/aks-set-context@v4
with:
cluster-name: ${{ env.CLUSTER_NAME }}
resource-group: ${{ steps.rg.outputs.result }}
admin: 'true'
use-kubelogin: 'true'
- name: Deploy to ${{ env.CLUSTER_NAME }}
uses: azure/k8s-deploy@v5
with:
manifests: ${{ steps.bake.outputs.manifestsBundle }}
images: |
${{ steps.meta.outputs.tags }}
namespace: ${{ env.ORG }}
action: deploy