Skip to content

Commit 64982f6

Browse files
authored
CLOUDP-218697: Detect helm chart releases happened (#295)
Signed-off-by: Jose Vazquez <[email protected]>
1 parent 2b0b265 commit 64982f6

File tree

3 files changed

+85
-1
lines changed

3 files changed

+85
-1
lines changed

.github/actions/releaser/cr.sh

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ main() {
2727
print_line_separator
2828
echo "Target folders: " "${target[@]}"
2929
release_charts_inside_folders "${target[@]}"
30+
31+
# double check targets are released or report the error
32+
check_charts_released "${target[@]}"
3033
}
3134

3235
print_line_separator() {
@@ -39,7 +42,7 @@ release_charts_inside_folders() {
3942

4043
prepare_helm_repo
4144

42-
# form list of folder which was changed
45+
# form list of folders which was changed
4346
for folder in "${folders[@]}"; do
4447
[[ ! -f "$charts_dir/$folder/Chart.yaml" ]] && continue
4548
print_line_separator
@@ -73,6 +76,40 @@ release_charts_inside_folders() {
7376
fi
7477
}
7578

79+
check_charts_released() {
80+
local folders=("$@")
81+
local unreleased_charts=()
82+
83+
prepare_helm_repo
84+
85+
# form a list of folders which were unreleased
86+
for folder in "${folders[@]}"; do
87+
[[ ! -f "$charts_dir/$folder/Chart.yaml" ]] && continue
88+
print_line_separator
89+
local chart_name
90+
local chart_version
91+
local chart_was_released
92+
93+
chart_name=$(read_chart_name "${charts_dir}/${folder}")
94+
chart_version=$(read_chart_version "${charts_dir}/${folder}")
95+
echo "Checking if \"$charts_dir/$folder\" has been released to the repo"
96+
chart_was_released=$(chart_released "${chart_name}" "${chart_version}")
97+
98+
echo "released result: \"${chart_was_released}\""
99+
100+
if [ -z "${chart_was_released}" ]; then
101+
unreleased_charts+=("$chart_name")
102+
fi
103+
done
104+
105+
if [[ -n "${unreleased_charts[*]}" ]]; then
106+
echo "FAIL: found unreleased charts:" "${unreleased_charts[@]}"
107+
exit 1
108+
else
109+
echo "PASS: all latest helm charts released for" "${folders[@]}"
110+
fi
111+
}
112+
76113
read_chart_name() {
77114
local chart_path=$1
78115
awk '/^name: /{print $2}' "$chart_path/Chart.yaml"

.github/workflows/check-released.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Check Released Charts
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * 1-5" # check-releases daily on work days
6+
workflow_dispatch:
7+
inputs:
8+
target:
9+
description: "target chart to release"
10+
type: string
11+
default: ""
12+
required: false
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Configure Git
22+
run: |
23+
git config user.name "$GITHUB_ACTOR"
24+
git config user.email "[email protected]"
25+
26+
- name: Install Helm
27+
uses: azure/setup-helm@v1
28+
with:
29+
version: v3.13.1
30+
31+
- name: Add Helm repos
32+
run: |
33+
helm repo add mongodb https://mongodb.github.io/helm-charts
34+
35+
- name: Allow script
36+
run: |
37+
chmod +x ./.github/actions/releaser/cr.sh
38+
39+
- name: Helm Chart Dryrun & Release check
40+
uses: ./.github/actions/releaser
41+
env:
42+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
43+
with:
44+
dryrun: true
45+
charts_repo_url: https://mongodb.github.io/helm-charts
46+
target: ${{ github.event.inputs.target }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ private/
44
*.tgz
55
.DS_Store
66
.idea
7+
.vscode
78
*.iml
89

910
# ignoring generated charts and chart locks

0 commit comments

Comments
 (0)