-
Notifications
You must be signed in to change notification settings - Fork 8
173 lines (154 loc) · 6.49 KB
/
pull-request.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
name: pull-request
on:
pull_request:
paths-ignore:
- '.github/**'
jobs:
pr-test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
ref: ${{ github.event.pull_request.head.ref }} # checkout the correct branch name
fetch-depth: 0 # fetch the whole repo history
- name: Git Version
id: auto_version
uses: codacy/[email protected]
with:
prefix: v
minor-identifier: /feat(ure)*:/
major-identifier: /breaking:/
- name: Set package version
id: version
run: |
if [[ $INPUT_VERSION ]]; then
echo "version=$INPUT_VERSION" >> $GITHUB_OUTPUT
else
echo "version=${{ steps.auto_version.outputs.version }}" >> $GITHUB_OUTPUT
fi
# DOCKER BUILD & PUSH
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Quay.io
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: quay.io
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
pull: true
tags: '${{ secrets.DOCKER_REGISTRY_NAME }}/csi-wekafs:${{ steps.auto_version.outputs.version }}'
cache-from: type=gha
cache-to: type=gha,mode=max
labels: |
revision=${{ steps.auto_version.outputs.version }}
quay.expires-after=14d
provenance: false # https://issues.redhat.com/browse/PROJQUAY-5013 quay doesn't support it
build-args: |
VERSION='${{ steps.auto_version.outputs.version }}'
platforms: linux/amd64,linux/arm64
# HELM
- name: Get Helm chart version
id: helm_version
run: |
out="$(echo "${{ steps.auto_version.outputs.version }}" | sed 's/^v//1')"
echo "helm_version=$out" >> $GITHUB_OUTPUT
- name: Update Helm chart version
uses: mikefarah/yq@master
with:
cmd: |
BASEDIR=charts/csi-wekafsplugin
DRIVER_VERSION="$(echo ${{ steps.version.outputs.version }} | sed 's/^v//1')"
CHART_VERSION="${{ steps.helm_version.outputs.helm_version }}"
APP_VERSION="${{ steps.version.outputs.version }}"
yq -i '.version = "'$CHART_VERSION'"' $BASEDIR/Chart.yaml
yq -i '.appVersion = "'$APP_VERSION'"' $BASEDIR/Chart.yaml
yq -i '.sources[0] = "https://github.com/weka/csi-wekafs/tree/v$CHART_VERSION/charts/csi-wekafsplugin"' $BASEDIR/Chart.yaml
yq -i '.csiDriverVersion = "'$DRIVER_VERSION'"' $BASEDIR/values.yaml
echo ------------------ values ------------------
cat $BASEDIR/values.yaml
echo --------------------chart ------------------
cat $BASEDIR/Chart.yaml
- name: helm-docs
uses: addnab/docker-run-action@v3
with:
image: jnorwood/helm-docs:latest
options: -v ${{ github.workspace }}:/data
run: |
cd /data
helm-docs -s file -c charts -o ../../README.md -t ../README.md.gotmpl
helm-docs -s file -c charts
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.10.0
- name: update Helm schema
run: |
helm plugin install https://github.com/karuppiah7890/helm-schema-gen.git
helm schema-gen charts/csi-wekafsplugin/values.yaml >| charts/csi-wekafsplugin/values.schema.json
# TEST CHART
- uses: actions/setup-python@v5
with:
python-version: '3.9'
check-latest: true
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --chart-dirs charts --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Run chart-testing (lint)
run: ct lint --chart-dirs charts --all --debug --validate-maintainers=false --target-branch ${{ github.event.repository.default_branch }}
- name: Create kind cluster
uses: helm/[email protected]
if: steps.list-changed.outputs.changed == 'true'
- name: Run chart-testing (install)
id: helm-test
run: |
ct install --print-config --chart-dirs charts --all --debug && \
echo "passed=true" >> $GITHUB_OUTPUT
if: steps.list-changed.outputs.changed == 'true'
# UPLOAD CHART TO S3
- name: Create Helm package
id: helm-package
run: |
helm package charts/csi-wekafsplugin
FILENAME="csi-wekafsplugin-${{ steps.helm_version.outputs.helm_version }}.tgz"
AWS_REGION=${{ secrets.AWS_ACCESS_SECRET_KEY }}
S3_BUCKET_NAME=${{ secrets.S3_BUCKET_NAME }}
URL="https://$S3_BUCKET_NAME.s3.$AWS_REGION.amazonaws.com"
echo "filename=$FILENAME" >> $GITHUB_OUTPUT
echo "url=$URL" >> $GITHUB_OUTPUT
- name: Install AWS CLI
id: install-aws-cli
uses: unfor19/install-aws-cli-action@v1
with:
version: 2
- name: Upload Helm package to S3
id: helm-s3-upload
run: |
export AWS_ACCESS_KEY_ID="${{ secrets.AWS_ACCESS_KEY_ID }}"
export AWS_SECRET_ACCESS_KEY="${{ secrets.AWS_SECRET_ACCESS_KEY}}"
export AWS_REGION="${{ secrets.AWS_REGION }}"
aws s3 cp ${{ steps.helm-package.outputs.filename }} "s3://${{ vars.AWS_BUCKET }}/"
echo "link=https://${{ vars.AWS_BUCKET }}.s3.${AWS_REGION}.amazonaws.com/${{ steps.helm-package.outputs.filename }}" >> $GITHUB_OUTPUT
if: steps.helm-test.outputs.passed == 'true'
- uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: csiBot
SLACK_ICON_EMOJI: ":robot_face:"
SLACK_TITLE: "New build was pushed"
SLACK_MESSAGE: "```helm upgrade csi-wekafs -n csi-wekafs --create-namespace -i ${{ steps.helm-s3-upload.outputs.link }} --set logLevel=6```"
SLACK_FOOTER: "Package path: ${{ steps.helm-s3-upload.outputs.link }}"