-
Notifications
You must be signed in to change notification settings - Fork 178
135 lines (126 loc) · 4.44 KB
/
ci-cd.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
# This workflow:
# - lints the chart, runs tests and verifies documentation is up to date
# Additionally if the event isn't a pull-request (and hence a merge/push to main):
# - sync README to gh-pages branch
# - release a new chart version if the version isn't already released
name: CI/CD
on:
push:
branches:
- main
pull_request:
# Cancel previous PR builds.
concurrency:
# Cancel all workflow runs except latest within a concurrency group. This is achieved by defining a concurrency group for the PR.
# Non-PR builds have singleton concurrency groups.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.number || github.sha }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.0.1
- name: Lint charts
run: ct lint --charts=charts/trino --validate-maintainers=false
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.0.1
- name: Create kind cluster
uses: helm/kind-action@v1.2.0
- name: Install charts
run: ct install --charts=charts/trino
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install Frigate
run: pip install frigate
- name: Check if chart README is in-sync
run: |
frigate gen charts/trino > charts/trino/README.md
if ! git diff --exit-code --quiet; then
cat << 'EOF'
charts/trino/README.md is not in sync with chart
Please update charts/trino/README.md by running:
python3 -m venv .venv && . .venv/bin/activate
pip install frigate
frigate gen charts/trino > charts/trino/README.md
Here's a diff of what's changed:
EOF
git diff
# fail the job
exit 1
else
echo "charts/trino/README.md is in-sync with chart"
fi
# Everything above is CI, everything here and below is for releases and runs only on non-pull-request events
sync-readme:
needs: [lint, test, docs]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Checkout main
uses: actions/checkout@v2
with:
path: main
- name: Checkout gh-pages
uses: actions/checkout@v2
with:
ref: gh-pages
path: gh-pages
- name: Copy all README files from main to gh-pages
run: |
cd main
# cp --parents preserves directory structure
find . -name 'README.md' -exec cp --parents '{}' "../gh-pages/" ';'
- name: Commit changes to gh-pages and push
run: |
cd gh-pages
git add .
git config user.name "GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
# Commit only if changes exist to avoid failure in this step
git diff-index --quiet HEAD || git commit --signoff -m "Sync READMEs from main"
git push
release:
needs: [lint, test, docs, sync-readme]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v2
with:
# history is required to generate changelog
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Build release changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v2.9.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
configuration: '.github/changelog-config.json'
outputFile: ${{ runner.temp }}/CHANGELOG.md
- name: Inspect changelog
run: cat ${{ runner.temp }}/CHANGELOG.md
- name: Release charts
uses: helm/chart-releaser-action@v1.3.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_RELEASE_NOTES_FILE: ${{ runner.temp }}/CHANGELOG.md
# If we didn't bump the chart version then we can skip the release
CR_SKIP_EXISTING: true