-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (104 loc) · 3.61 KB
/
deploy.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
name: Build and deploy
on:
push:
branches:
- main
paths-ignore:
- "*.md"
- "*.env"
env:
NAME: bqrator
FEATURE_REPOSITORY: oci://europe-north1-docker.pkg.dev/nais-io/nais/feature
CHART_PATH: "charts"
jobs:
build_and_push:
outputs:
version: ${{ steps.build_chart.outputs.version }}
name: ${{ steps.build_chart.outputs.name }}
permissions:
contents: "read"
id-token: "write"
name: build and push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: asdf-vm/actions/setup@v3
- id: asdf-cache
uses: actions/cache@v4
with:
path: ~/.asdf/
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
- uses: asdf-vm/actions/install@v3
if: steps.asdf-cache.outputs.cache-hit != 'true'
with:
before_install: |
asdf install golang latest
asdf global golang latest
- name: Find go cache dir
id: go-cache
run: |
go version
# Clear cache dirs to avoid error when restoring
go clean -cache -modcache
echo "gocache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "gomodcache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
- name: Cache go modules
uses: actions/cache@v4
with:
path: |
${{ steps.go-cache.outputs.gocache }}
${{ steps.go-cache.outputs.gomodcache }}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-2
- run: make test
- run: helm lint --strict ./charts
- run: make staticcheck
- run: make vulncheck
- name: Check code format and run code generators
run: |
make fmt
git diff --exit-code --name-only
- id: go_version
run: echo "go_version=$(asdf current golang | awk '{print $2}')" >> $GITHUB_OUTPUT
- uses: nais/platform-build-push-sign@main
id: build-push-sign
with:
name: ${{ env.NAME }}
build_args: |
GO_VERSION=${{ steps.go_version.outputs.go_version }}-
google_service_account: gh-${{ env.NAME }}
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}
push: true
- uses: azure/setup-helm@v4
name: "Setup Helm"
with:
version: "v3.14.2"
- name: Build Chart
id: build_chart
run: |-
suffix="$(date +%Y%m%d%H%M%S)"
orig_version=$(yq '.version' < "${{ env.CHART_PATH}}/Chart.yaml")
new_version="${orig_version}-$suffix"
sed -i "s/^version: .*/version: $new_version/g" "${{ env.CHART_PATH}}/Chart.yaml"
yq e -i '.image.tag = "${{ steps.build-push-sign.outputs.version }}"' "${{ env.CHART_PATH}}/values.yaml"
helm dependency update "${{ env.CHART_PATH}}"
helm package "${{ env.CHART_PATH}}" --destination .
name=$(yq '.name' "${{ env.CHART_PATH}}/Chart.yaml")
echo "name=$name" >> $GITHUB_OUTPUT
echo "chart=$name-$new_version.tgz" >> $GITHUB_OUTPUT
echo "version=$new_version" >> $GITHUB_OUTPUT
- name: Push Chart
run: |-
chart="${{ steps.build_chart.outputs.chart }}"
echo "Pushing: $chart"
helm push "$chart" ${{ env.FEATURE_REPOSITORY }}
rollout:
needs:
- build_and_push
runs-on: fasit-deploy
permissions:
id-token: write
steps:
- uses: nais/fasit-deploy@v2
with:
chart: ${{ env.FEATURE_REPOSITORY }}/${{ needs.build_and_push.outputs.name }}
version: ${{ needs.build_and_push.outputs.version }}