-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (149 loc) · 5.03 KB
/
build.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
163
164
165
166
167
168
169
170
171
172
173
name: Build
on:
push:
branches:
- main
tags:
- '*'
paths-ignore:
- .vscode/**
- docs/**
- README.md
- LICENSE
- CHANGELOG.md
- .github/**
- '!.github/workflows/build.yml'
- '**/README.md'
pull_request:
branches:
- main
paths-ignore:
- .vscode/**
- docs/**
- README.md
- LICENSE
- CHANGELOG.md
- .github/**
- '!.github/workflows/build.yml'
- '**/README.md'
workflow_dispatch:
env:
DOCKER_BUILDKIT: 1
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
REVIEW_APP_NAME_SUFFIX: ${{ (github.event_name == 'pull_request' && format('-ra{0}', github.event.number)) || '' }}
HOSTNAME_SUFFIX_FOR_PR: ${{ (github.event_name == 'pull_request' && format('-ra{0}.hst-smpls.falu.io', github.event.number)) || '' }}
jobs:
Build:
runs-on: ubuntu-latest
timeout-minutes: 10
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
outputs:
version: ${{ steps.gitversion.outputs.nuGetVersionV2 }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for GitVersion
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v2
with:
versionSpec: '5.x'
- name: Determine Version
uses: gittools/actions/gitversion/execute@v2
id: gitversion
with:
useConfigFile: true
- name: Replace tokens in deploy folder
if: ${{ github.actor != 'dependabot[bot]' }}
uses: qetza/replacetokens-action@v1.2.0
with:
sources: |
deploy/**/*.bicep
deploy/**/*.parameters.json
variables: '[${{ toJSON(env) }},${{ toJSON(secrets) }}]' # use env & secrets
log-level: 'debug'
if-no-files-found: 'error'
missing-var-log: 'error'
env:
DOCKER_IMAGE_TAG: ${{ steps.gitversion.outputs.nuGetVersionV2 }}
- name: Publish deploy artifact
if: ${{ github.actor != 'dependabot[bot]' }}
uses: actions/upload-artifact@v4
with:
path: deploy
name: deploy
retention-days: 1
- name: Pull Docker base images to warm cache
run: docker compose --file ${{ github.workspace }}/docker-compose.yml pull
env:
DOCKER_IMAGE_TAG: 'latest'
continue-on-error: true # Ignore errors if the image is not found
- name: Build docker images
run: >
docker compose
--file ${{ github.workspace }}/docker-compose.yml
build
--parallel
--build-arg BUILDKIT_INLINE_CACHE=1
env:
DOCKER_IMAGE_TAG: ${{ steps.gitversion.outputs.nuGetVersionV2 }}
- name: Log into registry
if: ${{ github.actor != 'dependabot[bot]' }}
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push docker images (NuGetVersionV2)
if: ${{ github.actor != 'dependabot[bot]' }}
run: docker compose --file ${{ github.workspace }}/docker-compose.yml push
env:
DOCKER_IMAGE_TAG: ${{ steps.gitversion.outputs.nuGetVersionV2 }}
- name: Push docker images (ShortSha)
if: ${{ github.actor != 'dependabot[bot]' && github.ref == 'refs/heads/main' }}
run: docker compose --file ${{ github.workspace }}/docker-compose.yml build --push
env:
DOCKER_IMAGE_TAG: ${{ steps.gitversion.outputs.shortSha }}
- name: Push docker images (latest)
if: ${{ github.actor != 'dependabot[bot]' && github.ref == 'refs/heads/main' }}
run: docker compose --file ${{ github.workspace }}/docker-compose.yml build --push
env:
DOCKER_IMAGE_TAG: 'latest'
Deploy:
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
needs: Build
timeout-minutes: 5
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false # cancelling will not stop ARM deployment
env:
version: ${{ needs.Build.outputs.version }}
steps:
- name: Download Artifact (deploy)
uses: actions/download-artifact@v4
with:
name: deploy
path: ${{ github.workspace }}/deploy
- name: Azure Login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy
uses: azure/arm-deploy@v2
with:
subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }}
resourceGroupName: 'FALU-SAMPLES'
template: '${{ github.workspace }}/deploy/main.bicep'
parameters: reviewAppNameSuffix=${{ env.REVIEW_APP_NAME_SUFFIX }}
deploymentName: ${{ env.version}}
scope: 'resourcegroup'
- name: Publish review app URLs
uses: thollander/actions-comment-pull-request@v2
if: ${{ github.event_name == 'pull_request' }}
with:
message: |
Deployment of your Review Apps succeeded.
You can check them out below
|Application|Url|
|--|--|
|Identity (Python)|https://identity-verification${{ env.HOSTNAME_SUFFIX_FOR_PR }}/ping|
comment_tag: samples