diff --git a/.github/actions/releaser/cr.sh b/.github/actions/releaser/cr.sh index 97ae47e3..e9e93ea7 100755 --- a/.github/actions/releaser/cr.sh +++ b/.github/actions/releaser/cr.sh @@ -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() { @@ -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 @@ -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" "${folders[@]}" + fi +} + read_chart_name() { local chart_path=$1 awk '/^name: /{print $2}' "$chart_path/Chart.yaml" diff --git a/.github/workflows/check-released.yml b/.github/workflows/check-released.yml new file mode 100644 index 00000000..ff1a44a2 --- /dev/null +++ b/.github/workflows/check-released.yml @@ -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 "$GITHUB_ACTOR@users.noreply.github.com" + + - 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 }} diff --git a/.gitignore b/.gitignore index 080902ef..39986885 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ private/ *.tgz .DS_Store .idea +.vscode *.iml # ignoring generated charts and chart locks