-
Notifications
You must be signed in to change notification settings - Fork 20
77 lines (76 loc) · 2.88 KB
/
ci-cd.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
on:
push:
branches:
- main
pull_request:
branches:
- main
name: chart-releaser
jobs:
helm-chart-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name 'github-actions'
git config user.email '[email protected]'
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.8.1
- uses: actions/setup-python@v4
with:
python-version: '3.9'
check-latest: true
- name: Install helm unittests
run: |
helm env
helm plugin install https://github.com/quintush/helm-unittest
- name: Install chart-testing
uses: helm/[email protected]
- if: github.event_name == 'pull_request'
name: Set target branch on pull_request
run: |
echo "TARGET_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
echo "SINCE=HEAD" >> $GITHUB_ENV
- if: github.event_name == 'push'
name: Set target branch on push
run: |
echo "TARGET_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
echo "SINCE=${{ github.event.before }}" >> $GITHUB_ENV
- name: Run chart-testing list-changed
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ env.TARGET_BRANCH }} --since ${{ env.SINCE }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Lint helm charts
if: steps.list-changed.outputs.changed == 'true' || github.event_name == 'push'
run: ct lint --config ct.yaml --validate-maintainers=false --target-branch ${{ env.TARGET_BRANCH }} --check-version-increment=${{ github.event_name == 'pull_request' }} --since=${{ env.SINCE }}
- name: Create k8s Kind Cluster
if: steps.list-changed.outputs.changed == 'true' || github.event_name == 'push'
uses: helm/[email protected]
- name: Install and test helm charts
if: steps.list-changed.outputs.changed == 'true' || github.event_name == 'push'
run: |
for TEST_DIR in tests/ci/*
do
echo "Running test $(pwd)/${TEST_DIR}"
ct install --target-branch ${{ env.TARGET_BRANCH }} --charts $(pwd)/${TEST_DIR}
done
- name: Run an upgrade test
if: steps.list-changed.outputs.changed == 'true' || github.event_name == 'push'
run: |
ct install --upgrade --target-branch ${{ env.TARGET_BRANCH }}
- if: github.event_name == 'push' && github.ref_name == 'main'
name: Run chart-releaser
uses: helm/[email protected]
with:
charts_dir: charts
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"