-
Notifications
You must be signed in to change notification settings - Fork 6
178 lines (152 loc) · 5.55 KB
/
Copy pathakkoma-chart-update.yaml
File metadata and controls
178 lines (152 loc) · 5.55 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
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
174
175
176
177
178
name: akkoma-chart-update
on:
schedule:
- cron: '0 8 * * *' # Daily at 8am UTC
workflow_dispatch:
inputs:
chart_version:
description: 'Force a specific chart version (tag name, e.g. chart-v0.3.1). If empty, uses latest release.'
required: false
default: ''
concurrency:
group: akkoma-chart-update
cancel-in-progress: true
env:
APP_DIR: applications/akkoma
REPLICATED_API_TOKEN: ${{ secrets.AKKOMA_REPLICATED_API_TOKEN }}
REPLICATED_APP: ${{ vars.AKKOMA_REPLICATED_APP || 'akkoma' }}
UPSTREAM_REPO: adamancini/akkoma-helm
CHART_PATH: charts/akkoma
jobs:
check-update:
runs-on: ubuntu-22.04
outputs:
needs_update: ${{ steps.compare.outputs.needs_update }}
new_version: ${{ steps.compare.outputs.new_version }}
tag: ${{ steps.upstream.outputs.tag }}
steps:
- uses: actions/checkout@v4
- name: Get latest upstream release
id: upstream
env:
GH_TOKEN: ${{ github.token }}
run: |
if [ -n "${{ inputs.chart_version }}" ]; then
tag="${{ inputs.chart_version }}"
else
response=$(gh api repos/${{ env.UPSTREAM_REPO }}/releases/latest 2>&1) || {
echo "ERROR: Failed to fetch latest release from ${{ env.UPSTREAM_REPO }}"
echo "Response: ${response}"
exit 1
}
tag=$(echo "${response}" | jq -r '.tag_name')
if [ -z "${tag}" ] || [ "${tag}" = "null" ]; then
echo "ERROR: No tag_name found in release response"
exit 1
fi
fi
# Extract semver: strip 'chart-v', 'chart-', 'v' prefixes
version="${tag#chart-}"
version="${version#v}"
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "Upstream tag: ${tag}, version: ${version}"
- name: Compare versions
id: compare
run: |
current=$(grep 'chartVersion:' ${{ env.APP_DIR }}/kots/akkoma-chart.yaml | awk '{print $2}')
new_version="${{ steps.upstream.outputs.version }}"
echo "Current: ${current}"
echo "Upstream: ${new_version}"
if [ "${current}" = "${new_version}" ]; then
echo "needs_update=false" >> "$GITHUB_OUTPUT"
echo "Versions match — nothing to do."
else
echo "needs_update=true" >> "$GITHUB_OUTPUT"
echo "new_version=${new_version}" >> "$GITHUB_OUTPUT"
echo "Update available: ${current} -> ${new_version}"
fi
build-and-release:
needs: check-update
if: needs.check-update.outputs.needs_update == 'true'
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ${{ env.APP_DIR }}
steps:
- uses: actions/checkout@v4
- name: Setup tools
uses: ./.github/actions/setup-tools
with:
app-dir: ${{ env.APP_DIR }}
- name: Clone upstream chart
run: |
tag="${{ needs.check-update.outputs.tag }}"
git clone --branch "${tag}" --depth 1 \
https://github.com/${{ env.UPSTREAM_REPO }}.git charts/akkoma-helm
- name: Build chart package
run: |
helm dependency update charts/akkoma-helm/${{ env.CHART_PATH }}
helm package charts/akkoma-helm/${{ env.CHART_PATH }} -d kots/
- name: Update chartVersion in akkoma-chart.yaml
run: |
version="${{ needs.check-update.outputs.new_version }}"
yq -i '.spec.chart.chartVersion = "'"${version}"'"' kots/akkoma-chart.yaml
- name: Lint Helm chart
run: |
helm lint charts/akkoma-helm/${{ env.CHART_PATH }}
- name: Lint KOTS manifests
run: |
replicated release lint --yaml-dir kots/
- name: Create Replicated release
run: |
version="${{ needs.check-update.outputs.new_version }}"
replicated release create \
--yaml-dir kots/ \
--promote Unstable \
--version "${version}"
- name: Clean up chart tarball
if: always()
run: |
rm -f kots/*.tgz
open-pr:
needs:
- check-update
- build-and-release
runs-on: ubuntu-22.04
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Setup tools
uses: ./.github/actions/setup-tools
with:
app-dir: ${{ env.APP_DIR }}
- name: Create PR
env:
GH_TOKEN: ${{ github.token }}
run: |
version="${{ needs.check-update.outputs.new_version }}"
branch="akkoma/chart-update-${version}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "${branch}"
yq -i '.spec.chart.chartVersion = "'"${version}"'"' \
${{ env.APP_DIR }}/kots/akkoma-chart.yaml
git add ${{ env.APP_DIR }}/kots/akkoma-chart.yaml
git commit -m "chore(akkoma): update chart to ${version}"
git push origin "${branch}"
body=$(cat <<EOF
## Summary
- Updates akkoma Helm chart to version ${version}
- Chart was built, linted, and released to the Unstable channel
## Automated
This PR was created by the \`akkoma-chart-update\` workflow.
EOF
)
gh pr create \
--title "chore(akkoma): update chart to ${version}" \
--body "${body}" \
--base main \
--head "${branch}"