-
Notifications
You must be signed in to change notification settings - Fork 7
163 lines (153 loc) Β· 5.83 KB
/
ci.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: π Push
on:
push:
branches:
- main
workflow_dispatch:
inputs:
force:
description: "Force deploy to prod"
type: boolean
default: false
required: true
jobs:
build:
secrets: inherit
name: Build
uses: equinor/spinedatasheetapi/.github/workflows/build.yml@main
release_please:
name: π Release Please
runs-on: ubuntu-latest
steps:
- name: Create Release
id: release
uses: google-github-actions/release-please-action@v3
with:
release-type: simple
package-name: spinedatasheet
changelog-types: >
[{"type":"feat","section":"Features","hidden":false},
{"type":"fix","section":"Bug Fixes","hidden":false},
{"type":"style", "section":"Cosmetic changes","hidden":false},
{"type":"docs","section":"For developers","hidden":false},
{"type":"refactor","section":"For developers","hidden":false},
{"type":"ci", "section":"For developers","hidden":false},
{"type":"chore", "section":"For developers","hidden":false},
{"type":"perf", "section":"Optimalization","hidden":false}]
outputs:
release_created: ${{ steps.release.outputs.release_created }}
deploy-ci:
name: 'π CI'
runs-on: ubuntu-latest
needs: build
environment: CI
permissions:
id-token: write
contents: read
steps:
- name: "Tag Image with Env"
uses: equinor/iaf-actions/add-container-tags@main
with:
build-id: ${{ github.sha }}
environment-shortname: 'ci'
registry: ${{ secrets.ACR_ENDPOINT }}
registry-repository: 'datasheetapi'
tag: 'ci-release'
client-id: ${{ secrets.ACR_USERNAME }}
client-secret: ${{ secrets.ACR_PASSWORD }}
- name: "Login to Azure"
uses: azure/login@v1
with:
client-id: ${{ vars.AZURE_SERVICE_PRINCIPAL_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
allow-no-subscriptions: true
- name: "Obtain token for upload"
shell: bash
run: echo FUSION_TOKEN=$(az account get-access-token --resource '${{ vars.RADIX_SERVICE_ID }}' | jq '.accessToken') >> $GITHUB_ENV
- name: "Trigger Radix Deploy"
shell: bash
run: |
curl -X POST \
-i \
-f \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${{ env.FUSION_TOKEN }}" \
-d '{"branch":"main", "triggeredBy":"${{ github.workflow_ref }}"}' \
"https://api.radix.equinor.com/api/v1/applications/datasheet/pipelines/build-deploy"
deploy_qa:
name: 'π QA'
runs-on: ubuntu-latest
needs: [release_please, deploy-ci]
if: ${{ needs.release_please.outputs.release_created || inputs.force }}
environment: QA
permissions:
id-token: write
contents: read
steps:
- name: Log into registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.ACR_ENDPOINT }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- run: |
docker image pull ${{ secrets.REGISTRY }}/datasheetapi:${{ github.sha }}
docker tag ${{ secrets.REGISTRY }}/datasheetapi:${{ github.sha }} ${{ secrets.REGISTRY }}/datasheetapi:qa-release
docker push ${{ secrets.REGISTRY }}/datasheetapi:qa-release
- name: "Login to Azure"
uses: azure/login@v1
with:
client-id: ${{ vars.AZURE_SERVICE_PRINCIPAL_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
allow-no-subscriptions: true
- name: "Obtain token for upload"
shell: bash
run: echo FUSION_TOKEN=$(az account get-access-token --resource '${{ vars.RADIX_SERVICE_ID }}' | jq '.accessToken') >> $GITHUB_ENV
- name: "Trigger Radix Deploy"
shell: bash
run: |
curl -X POST \
-i \
-f \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${{ env.FUSION_TOKEN }}" \
-d '{"branch":"main", "triggeredBy":"${{ github.workflow_ref }}"}' \
"https://api.radix.equinor.com/api/v1/applications/datasheet/pipelines/build-deploy"
deploy_prod:
name: 'π Prod'
runs-on: ubuntu-latest
needs: [deploy_qa]
environment: PROD
permissions:
id-token: write
contents: read
steps:
- name: Log into registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.ACR_ENDPOINT }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- run: |
docker image pull ${{ secrets.REGISTRY }}/datasheetapi:${{ github.sha }}
docker tag ${{ secrets.REGISTRY }}/datasheetapi:${{ github.sha }} ${{ secrets.REGISTRY }}/datasheetapi:prod-release
docker push ${{ secrets.REGISTRY }}/datasheetapi:prod-release
- name: "Login to Azure"
uses: azure/login@v1
with:
client-id: ${{ vars.AZURE_SERVICE_PRINCIPAL_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
allow-no-subscriptions: true
- name: "Obtain token for upload"
shell: bash
run: echo FUSION_TOKEN=$(az account get-access-token --resource '${{ vars.RADIX_SERVICE_ID }}' | jq '.accessToken') >> $GITHUB_ENV
- name: "Trigger Radix Deploy"
shell: bash
run: |
curl -X POST \
-i \
-f \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${{ env.FUSION_TOKEN }}" \
-d '{"branch":"main", "triggeredBy":"${{ github.workflow_ref }}"}' \
"https://api.radix.equinor.com/api/v1/applications/datasheet/pipelines/build-deploy"