-
Notifications
You must be signed in to change notification settings - Fork 5
230 lines (229 loc) · 7.75 KB
/
build.yaml
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: build-alb-images-and-chart
on:
workflow_dispatch:
inputs:
skip_test:
type: boolean
description: skil test
required: false
default: false
do_release:
type: boolean
description: do release
required: true
pull_request:
branches:
- master
- release-*
paths-ignore:
- 'docs/**'
- '**.md'
- '.github/VERSION'
push:
branches:
- master
- release-*
paths-ignore:
- 'docs/**'
- '**.md'
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
env:
GO_VERSION: ''
GOSEC_VERSION: '2.18.2'
HELM_VERSION: v3.13.3
SUBMARINER_VERSION: '0.16.2'
jobs:
build-alb:
name: Build alb
runs-on: ubuntu-22.04
outputs:
go-coverage: ${{ steps.alb-test.outputs.GO_COVERAGE }}
lua-coverage: ${{ steps.nginx-test.outputs.LUA_COVERAGE }}
strategy:
matrix:
platform:
- linux/amd64
# - linux/arm64
steps:
- uses: actions/checkout@v4
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: version # it will set the CURRENT_VERSION env
uses: HardNorth/[email protected]
with:
version-source: file
version-file: ./deploy/chart/alb/Chart.yaml
version-file-extraction-pattern: 'version: v([0-9]*\.[0-9]*\.[0-9]*)'
- uses: docker/setup-buildx-action@v3
- name: set release type
env:
RELEASE_ME: "${{ github.event.inputs.do_release == 'true' }}"
run: |
branch=$(echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | sed 's|/|-|g')
echo "branch is $branch"
if [[ "$RELEASE_ME" == "false" ]] && [[ "$branch" == "master" ]] ;then
echo "in master we still want to a pre-release"
echo "RELEASE_TYPE=pre-release" >> $GITHUB_ENV
exit
fi
if [[ "$RELEASE_ME" == "true" ]] ;then
echo "release it"
echo "RELEASE_TYPE=release" >> $GITHUB_ENV
exit
fi
echo "RELEASE_TYPE=no-release" >> $GITHUB_ENV
echo "not release"
- name: build
env:
RELEASE_ME: "${{ github.event.inputs.do_release == 'true' }}"
MATRIX_PLATFORM: "${{matrix.platform }}"
run: |
set -x
./scripts/run-like-github-actions.sh build-alb
platform=$(echo "$MATRIX_PLATFORM" | sed 's|/|-|g')
echo "artifactPath=./alb-$platform.tar" >> $GITHUB_ENV
echo "artifactName=alb-$platform" >> $GITHUB_ENV
- name: Upload alb images to artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifactName }}
path: ${{ env.artifactPath }}
- name: test alb go
id: alb-test
if: ${{ (matrix.platform == 'linux/amd64' ) && (!inputs.skip_test) }}
env:
MATRIX_PLATFORM: "${{ matrix.platform }}"
run: |
set -x
echo "FROM --platform=\${{ matrix.platform }} | $MATRIX_PLATFORM "
# ./scripts/run-like-github-actions.sh test-alb-go
lua_cov=20
echo "GO_COVERAGE=$gocov" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
- name: test alb nginx
id: nginx-test
if: ${{ (matrix.platform == 'linux/amd64' ) && (!inputs.skip_test) }}
env:
MATRIX_PLATFORM: "${{matrix.platform }}"
run: |
set -x
# ./scripts/run-like-github-actions.sh test-alb-nginx
echo "in gh ci"
# cat ./luacov.summary
# line_cov=$(cat ./luacov.summary |grep Total|awk '{print $4}'|awk -F% '{print $1}')
# echo "lua coverage is $line_cov%"
lua_cov=10
echo "LUA_COVERAGE=$luacov" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
release-alb:
name: Release alb
runs-on: ubuntu-22.04
needs: [build-alb]
steps:
- uses: actions/checkout@v4
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: version # it will set the CURRENT_VERSION env
uses: HardNorth/[email protected]
with:
version-source: file
version-file: ./deploy/chart/alb/Chart.yaml
version-file-extraction-pattern: 'version: v([0-9]*\.[0-9]*\.[0-9]*)'
- name: cr
uses: helm/[email protected]
with:
install_only: true
- uses: azure/setup-helm@v3
with:
version: '${{ env.HELM_VERSION }}'
- uses: actions/download-artifact@master # TODO download arm artifact
with:
name: alb-linux-amd64
- name: show artifact
run: |
ls -l
- name: set release type
env:
RELEASE_ME: "${{ github.event.inputs.do_release == 'true' }}"
run: |
branch=$(echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | sed 's|/|-|g')
echo "branch is $branch"
if [[ "$RELEASE_ME" == "false" ]] && [[ "$branch" == "master" ]] ;then
echo "in master we still want to a pre-release"
echo "RELEASE_TYPE=pre-release" >> $GITHUB_ENV
exit
fi
if [[ "$RELEASE_ME" == "true" ]] ;then
echo "release it"
echo "RELEASE_TYPE=release" >> $GITHUB_ENV
exit
fi
echo "RELEASE_TYPE=no-release" >> $GITHUB_ENV
echo "not release"
- name: gen alb chart
run: |
echo "gen alb chart"
env
./scripts/run-like-github-actions.sh gen-chart-artifact
- uses: actions/upload-artifact@v4
with:
name: alb-chart
path: alauda-alb2.tgz
- name: release
if: ${{ env.RELEASE_TYPE != 'no-release' }}
env:
GH_TOKEN: ${{ github.token }}
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_CLI_EXPERIMENTAL: enabled
run: |
./scripts/run-like-github-actions.sh release-alb
update-coverage:
name: update coverage
runs-on: ubuntu-22.04
needs: [build-alb]
env:
GO_COVERAGE: ${{ needs.build-alb.outputs.go-coverage }}
LUA_COVERAGE: ${{ needs.build-alb.outputs.lua-coverage }}
steps:
- name: debug
run: |
env
set -x
echo "GO_COVERAGE=$GO_COVERAGE"
echo "LUA_COVERAGE=$LUA_COVERAGE"
- name: Checkout gh-pages
uses: actions/checkout@v3
with:
ref: gh-pages
- name: Create Badges
shell: bash
run: |
set -x
npm i -g badgen-cli
GO_COLOR=$(node -p '+process.env.GO_COVERAGE >= 95 ? `green` : `orange`')
LUA_COLOR=$(node -p '+process.env.LUA_COVERAGE >= 95 ? `green` : `orange`')
mkdir -p badges
badgen -j coverage -s "$GO_COVERAGE%" -c $GO_COLOR > badges/go-coverage.svg
badgen -j coverage -s $LUA_COVERAGE% -c $LUA_COLOR > badges/lua-coverage.svg
- name: Deploy Badges
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Update badges [skip ci]"
branch: gh-pages
skip_fetch: true
skip_checkout: true
# Without this, will get Error:
# Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/coverage-badge-action/coverage-badge-action/action.yml'.
# Did you forget to run actions/checkout before running your local action?
- name: Checkout Back
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}