-
Notifications
You must be signed in to change notification settings - Fork 7
149 lines (128 loc) · 4.56 KB
/
build-lambda-v2.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
name: Build lambda
on:
workflow_call:
inputs:
lambda-name: #lambda-backoffice
required: true
type: string
test-project: #StreetNameRegistry.Tests
required: false
type: string
build-project: #StreetNameRegistry.Api.BackOffice.Handlers.Lambda
required: true
type: string
semver:
required: true
type: string
runtime:
required: false
type: string
dotnet-version:
required: false
type: string
prerestore-script:
required: false
type: string
jobs:
build-lambda:
runs-on: ubuntu-latest
steps:
- name: Check version
shell: bash
run: echo $SEMVER
env:
SEMVER: ${{ inputs.semver }}
- name: Checkout Code
uses: actions/checkout@v4
- name: Parse repository name
run: echo REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") >> $GITHUB_ENV
shell: bash
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ inputs.dotnet-version || secrets.VBR_DOTNET_VERSION }}
cache: true
cache-dependency-path: "**/packages.lock.json"
- name: .NET version
shell: bash
run: dotnet --info
- name: Pre-restore
if: ${{ inputs.prerestore-script != '' && inputs.prerestore-script != 'none' }}
shell: bash
run: ${{ inputs.prerestore-script }}
- name: Restore dotnet tools
shell: bash
run: |
dotnet tool restore
- name: Dotnet restore tests
if: ${{ inputs.test-project != '' && inputs.test-project != 'none' }}
shell: bash
run: dotnet restore test/${{ inputs.test-project }} --locked-mode --runtime $RUNTIME
env:
RUNTIME: ${{ inputs.runtime || 'linux-x64' }}
- name: Dotnet build tests
if: ${{ inputs.test-project != '' && inputs.test-project != 'none' }}
shell: bash
run: dotnet build --no-restore --runtime $RUNTIME test/${{ inputs.test-project }}
env:
RUNTIME: ${{ inputs.runtime || 'linux-x64' }}
- name: Run all tests
if: ${{ inputs.test-project != '' && inputs.test-project != 'none' }}
run: dotnet test test/${{ inputs.test-project }}
- name: Dotnet restore
shell: bash
run: dotnet restore src/${{ inputs.build-project }} --locked-mode --runtime $RUNTIME
env:
RUNTIME: ${{ inputs.runtime || 'linux-x64' }}
- name: Dotnet build
shell: bash
run: dotnet build --no-restore -c Release --runtime $RUNTIME src/${{ inputs.build-project }} -p:Version=$VERSION -p:FileVersion=$VERSION -p:Copyright="$COPYRIGHT" -p:Company="$COMPANY" -p:Product="$PRODUCT" -p:InformationalVersion=$GIT_HASH
env:
RUNTIME: ${{ inputs.runtime || 'linux-x64' }}
VERSION: ${{ inputs.semver }}
COPYRIGHT: "Copyright \\(c\\) Vlaamse overheid"
PRODUCT: "Basisregisters Vlaanderen"
COMPANY: "Vlaamse overheid"
GIT_HASH: ${{ github.sha }}
- name: Dotnet publish
shell: bash
run: dotnet publish -o dist/${{ inputs.build-project }}/linux --no-build --no-restore -c Release --runtime $RUNTIME -p:PublishReadyToRun=true src/${{ inputs.build-project }}
env:
RUNTIME: ${{ inputs.runtime || 'linux-x64' }}
- name: Package Lambda functions
if: env.RELEASE_VERSION != 'none'
shell: bash
run: |
echo Zip lambda functions
pushd dist/${{ inputs.build-project }}/linux
echo cleanup datadog
rm -rf datadog
echo zip -r lambda.zip .
zip -r lambda.zip .
popd
- name: Upload Lambda
if: inputs.semver != 'none'
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.lambda-name }}-${{ inputs.semver }}
path: dist/${{ inputs.build-project }}/linux/lambda.zip
# - name: Shows logs ACM container
# if: ${{ failure() }}
# shell: bash
# run: |
# docker logs acm
# - name: Shows logs elasticsearch container
# if: ${{ failure() }}
# shell: bash
# run: |
# docker logs elasticsearch
# - name: Shows logs db container
# if: ${{ failure() }}
# shell: bash
# run: |
# docker logs db
# - name: Shows logs minio container
# if: ${{ failure() }}
# shell: bash
# run: |
# docker logs minio