-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (86 loc) · 2.83 KB
/
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
name: Publish to registry
on:
push:
branches:
- main
permissions:
id-token: write
contents: read
jobs:
prepare:
name: Calculate next version
runs-on: ubuntu-latest
outputs:
semver: ${{ steps.gitversion.outputs.SemVer }}
major: ${{ steps.gitversion.outputs.Major }}
minor: ${{ steps.gitversion.outputs.Minor }}
patch: ${{ steps.gitversion.outputs.Patch }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.x"
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
infra:
name: Infrastructure
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
infrastructure
- name: Az CLI login
uses: azure/login@v2
with:
client-id: ${{ secrets.TRICEP_CLIENT_ID }}
tenant-id: ${{ secrets.TRICEP_TENANT_ID }}
subscription-id: ${{ secrets.TRICEP_SUBSCRIPTION_ID }}
- name: Deploy bicep
uses: Azure/cli@v2
with:
azcliversion: 2.66.0
inlineScript: |
az deployment sub create \
--location westeurope \
--template-file infrastructure/main.bicep \
--parameters infrastructure/params/main.prd.bicepparam \
publish:
name: Publish
runs-on: ubuntu-latest
needs: [ prepare, infra ]
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
src
- name: Az CLI login
uses: azure/login@v2
with:
client-id: ${{ secrets.TRICEP_CLIENT_ID }}
tenant-id: ${{ secrets.TRICEP_TENANT_ID }}
subscription-id: ${{ secrets.TRICEP_SUBSCRIPTION_ID }}
- name: Publish Bicep module
uses: azure/cli@v2
with:
inlineScript: |
cd src
for x in $(find . -type d -name internal -prune -o -type f -name "*.bicep"); do
name=${x#"./"}
name=${name%".bicep"}
name="br:${{ secrets.ACR_LOGIN_SERVER }}/$name"
major="${{needs.prepare.outputs.major}}"
minor="${{needs.prepare.outputs.minor}}"
patch="${{needs.prepare.outputs.patch}}"
az bicep publish --file "$x" --target "$name:latest" --with-source --force
az bicep publish --file "$x" --target "$name:$major" --with-source --force
az bicep publish --file "$x" --target "$name:$major.$minor" --with-source --force
az bicep publish --file "$x" --target "$name:$major.$minor.$patch" --with-source
done