-
Notifications
You must be signed in to change notification settings - Fork 3
142 lines (127 loc) · 4.15 KB
/
altinn-monitor-test-rg-deploy.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
132
133
134
135
136
137
138
139
140
141
142
name: Altinn Monitor Test rg
on:
push:
branches:
- main
paths:
- .github/workflows/altinn-monitor-test-rg-deploy.yml
- actions/terraform/apply/**
- actions/terraform/plan/**
- infrastructure/adminservices-test/altinn-monitor-test-rg/**
pull_request:
branches:
- main
paths:
- .github/workflows/altinn-monitor-test-rg-deploy.yml
- actions/terraform/apply/**
- actions/terraform/plan/**
- infrastructure/adminservices-test/altinn-monitor-test-rg/**
workflow_dispatch:
inputs:
log_level:
required: true
description: Terraform Log Level
default: INFO
type: choice
options:
- TRACE
- DEBUG
- INFO
- WARN
- ERROR
env:
ENVIRONMENT: test
TF_STATE_NAME: altinn-monitor-test-rg.tfstate
TF_PROJECT: ./infrastructure/adminservices-test/altinn-monitor-test-rg
ARM_CLIENT_ID: ${{ vars.TF_AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: 1ce8e9af-c2d6-44e7-9c5e-099a308056fe
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
plan:
name: Plan
environment: reader
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
# TODO: This needs a review once I'm done with the PoC
- name: Azure login
uses: azure/login@v2
with:
client-id: ${{ env.ARM_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ env.ARM_SUBSCRIPTION_ID }}
# TODO: This needs a review once I'm done with the PoC
- name: Populate kubeconfig with k6 context
id: populate_kubeconfig_with_k6_context
shell: bash
run: |
if ! az aks install-cli; then
echo "Failed to install kubectl CLI"
exit 1
fi
if ! az aks get-credentials --resource-group k6tests-rg --name k6tests-cluster; then
echo "Failed to populate kubeconfig"
exit 1
fi
if ! kubelogin convert-kubeconfig -l azurecli; then
echo "Failed to convert kubeconfig"
exit 1
fi
- name: Terraform Plan
uses: altinn/altinn-platform/actions/terraform/plan@main
with:
working_directory: ${{ env.TF_PROJECT }}
oidc_type: environment
oidc_value: ${{ env.ENVIRONMENT }}
arm_client_id: ${{ env.ARM_CLIENT_ID }}
arm_subscription_id: ${{ env.ARM_SUBSCRIPTION_ID }}
tf_state_name: ${{ env.TF_STATE_NAME }}
gh_token: ${{ secrets.GITHUB_TOKEN }}
tf_version: latest
deploy:
name: Deploy
environment: test
if: github.ref == 'refs/heads/main'
needs: plan
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
# TODO: This needs a review once I'm done with the PoC
- name: Azure login
uses: azure/login@v2
with:
client-id: ${{ env.ARM_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ env.ARM_SUBSCRIPTION_ID }}
# TODO: This needs a review once I'm done with the PoC
- name: Populate kubeconfig with k6 context
id: populate_kubeconfig_with_k6_context
shell: bash
run: |
if ! az aks install-cli; then
echo "Failed to install kubectl CLI"
exit 1
fi
if ! az aks get-credentials --resource-group k6tests-rg --name k6tests-cluster; then
echo "Failed to populate kubeconfig"
exit 1
fi
if ! kubelogin convert-kubeconfig -l azurecli; then
echo "Failed to convert kubeconfig"
exit 1
fi
- name: Terraform Apply
uses: altinn/altinn-platform/actions/terraform/apply@main
with:
working_directory: ${{ env.TF_PROJECT }}
oidc_type: environment
oidc_value: ${{ env.ENVIRONMENT }}
arm_client_id: ${{ env.ARM_CLIENT_ID }}
arm_subscription_id: ${{ env.ARM_SUBSCRIPTION_ID }}
tf_state_name: ${{ env.TF_STATE_NAME }}
tf_version: latest