-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (114 loc) · 4.52 KB
/
helm-chart-test.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
name: Lint, Test and Release Charts
on:
push:
branches:
- 'develop'
- 'main'
paths:
- 'helm-chart/kubeinfo-backend/**/*.yaml'
pull_request:
branches:
- 'develop'
- 'main'
paths:
- 'helm-chart/kubeinfo-backend/**/*.yaml'
permissions:
contents: write
jobs:
Lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Set up chart-testing
uses: helm/[email protected]
- name: Get changed files in the helm folder
id: changed-files-helm-chart
uses: tj-actions/changed-files@v40
with:
files_yaml: |
helm:
- helm-chart/kubeinfo-backend/*.{yaml,tpl}
- '!helm-chart/kubeinfo-backend/Chart.yaml'
- name: Run chart-testing (lint)
run: ct lint --config ct.yaml --all
if: steps.changed-files-helm-chart.outputs.helm_any_changed == 'true'
- name: Create kind cluster
uses: helm/[email protected]
if: steps.changed-files-helm-chart.outputs.helm_any_changed == 'true'
- name: Run chart-testing (install)
run: ct install --config ct.yaml --all
if: steps.changed-files-helm-chart.outputs.helm_any_changed == 'true'
Release:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
needs: Lint-test
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.SEMANTIC_TOKEN }}
- name: Set up Helm
uses: azure/setup-helm@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Get changed files in the helm folder
id: changed-files-helm-chart
uses: tj-actions/changed-files@v40
with:
files_yaml: |
helm:
- helm-chart/kubeinfo-backend/*.{yaml,tpl}
- '!helm-chart/kubeinfo-backend/Chart.yaml'
chart_version:
- 'helm-chart/kubeinfo-backend/Chart.yaml'
- name: Install PyBump
run: |
python3 -m pip install pybump
shell: bash
if: steps.changed-files-helm-chart.outputs.helm_any_changed == 'true' && steps.changed-files-helm-chart.outputs.chart_version_any_changed != 'true' && github.ref == 'refs/heads/main'
- name: Automated Version Bump
id: version-bump
run: |
echo "VER=$(pybump bump --file helm-chart/kubeinfo-backend/Chart.yaml --level patch)" >> $GITHUB_OUTPUT
shell: bash
if: steps.changed-files-helm-chart.outputs.helm_any_changed == 'true' && steps.changed-files-helm-chart.outputs.chart_version_any_changed != 'true' && github.ref == 'refs/heads/main'
- name: Output Name
id: chart-name
run: |
echo "::set-output name=chart::$(basename helm-chart/kubeinfo-backend)"
shell: bash
if: steps.changed-files-helm-chart.outputs.helm_any_changed == 'true' && steps.changed-files-helm-chart.outputs.chart_version_any_changed != 'true' && github.ref == 'refs/heads/main'
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
if: github.ref == 'refs/heads/main'
- name: GIT Commit
run: |
git add helm-chart/kubeinfo-backend/Chart.yaml
git commit -m "Automatic bump Helm chart version to ${{ steps.version-bump.outputs.VER }}"
if: steps.changed-files-helm-chart.outputs.helm_any_changed == 'true' && steps.changed-files-helm-chart.outputs.chart_version_any_changed != 'true' && github.ref == 'refs/heads/main'
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.SEMANTIC_TOKEN }}
if: steps.changed-files-helm-chart.outputs.helm_any_changed == 'true' && steps.changed-files-helm-chart.outputs.chart_version_any_changed != 'true' && github.ref == 'refs/heads/main'
- name: Run chart-releaser
uses: helm/[email protected]
with:
charts_dir: helm-chart
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: steps.changed-files-helm-chart.outputs.chart_version_any_changed == 'true' && github.ref == 'refs/heads/main'