Skip to content

Commit

Permalink
CLOUDP-226369: Allow backport releases
Browse files Browse the repository at this point in the history
Signed-off-by: jose.vazquez <[email protected]>
  • Loading branch information
josvazg committed Feb 5, 2024
1 parent 2fcc060 commit 9749552
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .github/actions/releaser/cr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ set -o errexit
set -o nounset
set -o pipefail

set -x

main() {
local version=${VERSION:-v1.2.1}
local charts_dir=${CHART_DIR:-charts}
Expand Down Expand Up @@ -42,6 +44,7 @@ release_charts_inside_folders() {

prepare_helm_repo

# shellcheck disable=SC2128
# form list of folders which was changed
for folder in "${folders[@]}"; do
[[ ! -f "$charts_dir/$folder/Chart.yaml" ]] && continue
Expand All @@ -52,13 +55,12 @@ release_charts_inside_folders() {

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 chart is not released or folder has change, then remember as changed_charts
if [ -z "${chart_was_released}" ] || has_changed "$folder"; then
if [ "${chart_was_released}" != "Not found" ] || has_changed "$folder"; then
changed_charts+=("$folder")
fi
done
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:
- '.github/**'
workflow_dispatch:
inputs:
backport-branch:
description: "Select backport branch if different from 'main'"
type: string
default: "main"
required: true
target:
description: "target chart to release"
type: string
Expand All @@ -22,10 +27,20 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
BACKPORT_BRANCH: ${{ github.event.inputs.backport-branch || 'main' }}
BACKPORT_DIR: 'backport'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Checkout Backport branch
uses: actions/checkout@v4
if: github.event.inputs.backport-branch != 'main'
with:
ref: ${{ env.BACKPORT_BRANCH }}
path: ${{ env.BACKPORT_DIR }}

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
Expand Down Expand Up @@ -64,7 +79,9 @@ jobs:
uses: ./.github/actions/releaser
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CHARTS_DIR: ${{ github.event.inputs.backport-branch == 'main' && 'charts' || format('{0}/charts', env.BACKPORT_DIR) }}
with:
charts_repo_url: https://mongodb.github.io/helm-charts
target: ${{ github.event.inputs.target }}
dryrun: ${{ github.event.inputs.dryrun }}
charts_dir: ${{ env.CHARTS_DIR }}

0 comments on commit 9749552

Please sign in to comment.