Skip to content

Commit

Permalink
CLOUDP-218697: Detect helm chart releases happened
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Vazquez <[email protected]>
  • Loading branch information
josvazg committed Dec 20, 2023
1 parent f802c79 commit 9b09dc9
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
39 changes: 38 additions & 1 deletion .github/actions/releaser/cr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ main() {
print_line_separator
echo "Target folders: " "${target[@]}"
release_charts_inside_folders "${target[@]}"

# double check targets are released or report the error
check_charts_released "${target[@]}"
}

print_line_separator() {
Expand All @@ -39,7 +42,7 @@ release_charts_inside_folders() {

prepare_helm_repo

# form list of folder which was changed
# form list of folders which was changed
for folder in "${folders[@]}"; do
[[ ! -f "$charts_dir/$folder/Chart.yaml" ]] && continue
print_line_separator
Expand Down Expand Up @@ -73,6 +76,40 @@ release_charts_inside_folders() {
fi
}

check_charts_released() {
local folders=("$@")
local unreleased_charts=()

prepare_helm_repo

# form a list of folders which were unreleased
for folder in "${folders[@]}"; do
[[ ! -f "$charts_dir/$folder/Chart.yaml" ]] && continue
print_line_separator
local chart_name
local chart_version
local chart_was_released

chart_name=$(read_chart_name "${charts_dir}/${folder}")
chart_version=$(read_chart_version "${charts_dir}/${folder}")
echo "Checking if \"$charts_dir/$folder\" has been released to the repo"
chart_was_released=$(chart_released "${chart_name}" "${chart_version}")

echo "released result: \"${chart_was_released}\""

if [ -z "${chart_was_released}" ]; then
unreleased_charts+=("$chart_name")
fi
done

if [[ -n "${unreleased_charts[*]}" ]]; then
echo "FAIL: found unreleased charts:" "${unreleased_charts[@]}"
exit 1
else
echo "PASS: all latest helm charts released for" "${folder[@]}"
fi
}

read_chart_name() {
local chart_path=$1
awk '/^name: /{print $2}' "$chart_path/Chart.yaml"
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/check-released.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Check Released Charts

on:
schedule:
- cron: "0 0 * * 1-5" # check-releases daily on work days
workflow_dispatch:
inputs:
target:
description: "target chart to release"
type: string
default: ""
required: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.13.1

- name: Add Helm repos
run: |
helm repo add mongodb https://mongodb.github.io/helm-charts
- name: Allow script
run: |
chmod +x ./.github/actions/releaser/cr.sh
- name: Helm Chart Dryrun & Release check
uses: ./.github/actions/releaser
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
dryrun: true
charts_repo_url: https://mongodb.github.io/helm-charts
target: ${{ github.event.inputs.target }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ private/
*.tgz
.DS_Store
.idea
.vscode
*.iml

# ignoring generated charts and chart locks
Expand Down

0 comments on commit 9b09dc9

Please sign in to comment.