From 5f7c47d92b5b44a5554a0e3e238d8f46dcecd211 Mon Sep 17 00:00:00 2001 From: Tom Lebreux Date: Wed, 26 Mar 2025 21:00:27 -0400 Subject: [PATCH] Prevent creating Rancher PR if RC not yet in rancher/charts --- .github/workflows/release-rancher.yaml | 36 +++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-rancher.yaml b/.github/workflows/release-rancher.yaml index b64679d8c..5761f0c1e 100644 --- a/.github/workflows/release-rancher.yaml +++ b/.github/workflows/release-rancher.yaml @@ -29,6 +29,9 @@ jobs: # Required for vault id-token: write steps: + - name: Install dependencies + run: sudo snap install yq --channel=v4/stable + - uses: actions/checkout@v4 with: ref: "${{ env.WEBHOOK_REF }}" @@ -59,6 +62,36 @@ jobs: # Allow making git push request later on persist-credentials: true + - name: Find charts branch + id: find_charts_branch + run: | + cd rancher + # Extract dev-v2.9 out of the following line: + # ChartDefaultBranch = NewSetting("chart-default-branch", "dev-v2.9") + charts_branch=$(grep '"chart-default-branch"' pkg/settings/setting.go | cut -d'"' -f4) + echo "charts_branch=$charts_branch" >> $GITHUB_OUTPUT + + - uses: actions/checkout@v4 + with: + repository: ${{ github.repository_owner }}/charts + ref: "${{ steps.find_charts_branch.outputs.charts_branch }}" + path: charts + + # Prevents the Rancher CI to continuously fail while the webhook RC is not + # yet added to charts' index.yaml file due to caching. + - name: Verify RC exists + env: + CHARTS_BRANCH: "${{ steps.find_charts_branch.outputs.charts_branch }}" + run: | + cd charts + new_webhook_short=$(echo "$NEW_WEBHOOK" | sed 's|^v||') # e.g. 0.5.2-rc.3 + # Empty output if the version is not found, otherwise the version will be outputed. + found=$(yq ".entries.rancher-webhook[].version | select(. == \"*$new_webhook_short\")" index.yaml) + if [ -z "$found" ]; then + echo "rancher-webhook RC version $NEW_WEBHOOK not found in charts (branch=$CHARTS_BRANCH). Aborting." + exit 1 + fi + - name: Configure the committer run: | cd rancher @@ -69,9 +102,6 @@ jobs: GH_TOKEN: ${{ steps.app-token.outputs.token }} APP_USER: "${{ steps.app-token.outputs.app-slug }}[bot]" - - name: Install dependencies - run: sudo snap install yq --channel=v4/stable - - name: Run release script run: | cd rancher