-
-
Notifications
You must be signed in to change notification settings - Fork 20
105 lines (91 loc) · 4.21 KB
/
Copy pathrelease-chart.yaml
File metadata and controls
105 lines (91 loc) · 4.21 KB
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
name: Release Chart
on:
push:
branches:
- main
paths:
- "charts/marmot/Chart.yaml"
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name marmot-helm-bot
git config user.email marmot-helm-bot@marmotdata.com
- name: Get chart version
id: chart_version
run: |
cd charts/marmot
echo "CHART_VERSION=$(grep -o 'version: [0-9.]*' Chart.yaml | awk '{print $2}')" >> "$GITHUB_OUTPUT"
- name: Check if version changed
id: version_check
run: |
PREV_VERSION=$(git show HEAD~1:charts/marmot/Chart.yaml | grep -o 'version: [0-9.]*' | awk '{print $2}' || echo "0.0.0")
CURRENT_VERSION="${{ steps.chart_version.outputs.CHART_VERSION }}"
if [ "$PREV_VERSION" != "$CURRENT_VERSION" ]; then
echo "VERSION_CHANGED=true" >> "$GITHUB_OUTPUT"
echo "Chart version changed from $PREV_VERSION to $CURRENT_VERSION"
else
echo "VERSION_CHANGED=false" >> "$GITHUB_OUTPUT"
echo "Chart version unchanged: $CURRENT_VERSION"
fi
- name: Check if tag exists in charts repo
id: tag_exists
if: steps.version_check.outputs.VERSION_CHANGED == 'true'
run: |
TAG_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: token ${{ secrets.CHARTS_REPO_TOKEN }}" \
"https://api.github.com/repos/marmotdata/charts/git/refs/tags/marmot-${{ steps.chart_version.outputs.CHART_VERSION }}")
if [ "$TAG_EXISTS" = "200" ]; then
echo "TAG_EXISTS=true" >> "$GITHUB_OUTPUT"
else
echo "TAG_EXISTS=false" >> "$GITHUB_OUTPUT"
fi
- name: Lint chart
if: steps.version_check.outputs.VERSION_CHANGED == 'true' && steps.tag_exists.outputs.TAG_EXISTS == 'false'
run: make chart-lint
- name: Test chart
if: steps.version_check.outputs.VERSION_CHANGED == 'true' && steps.tag_exists.outputs.TAG_EXISTS == 'false'
run: make chart-test
- name: Create tag and release in charts repo
if: steps.version_check.outputs.VERSION_CHANGED == 'true' && steps.tag_exists.outputs.TAG_EXISTS == 'false'
run: |
TAG_NAME="marmot-${{ steps.chart_version.outputs.CHART_VERSION }}"
# Create tag
curl -X POST \
-H "Authorization: token ${{ secrets.CHARTS_REPO_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/marmotdata/charts/git/refs \
-d "{
\"ref\": \"refs/tags/$TAG_NAME\",
\"sha\": \"$(curl -s -H 'Authorization: token ${{ secrets.CHARTS_REPO_TOKEN }}' https://api.github.com/repos/marmotdata/charts/git/refs/heads/main | jq -r .object.sha)\"
}"
# Create release
curl -X POST \
-H "Authorization: token ${{ secrets.CHARTS_REPO_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/marmotdata/charts/releases \
-d "{
\"tag_name\": \"$TAG_NAME\",
\"name\": \"Marmot Chart v${{ steps.chart_version.outputs.CHART_VERSION }}\",
\"body\": \"Marmot Helm Chart v${{ steps.chart_version.outputs.CHART_VERSION }}\\n\\nInstall with:\\n\\\`\\\`\\\`bash\\nhelm repo add marmotdata https://marmotdata.github.io/charts\\nhelm install marmot marmotdata/marmot --version ${{ steps.chart_version.outputs.CHART_VERSION }}\\n\\\`\\\`\\\`\"
}"
- name: Publish Helm chart
if: steps.version_check.outputs.VERSION_CHANGED == 'true' && steps.tag_exists.outputs.TAG_EXISTS == 'false'
uses: stefanprodan/helm-gh-pages@master
with:
token: ${{ secrets.CHARTS_REPO_TOKEN }}
owner: marmotdata
repository: charts
branch: main
target_dir: marmot
index_dir: .
charts_dir: charts/
charts_url: https://marmotdata.github.io/charts
commit_username: marmot-helm-bot
commit_email: marmot-helm-bot@marmotdata.com