Skip to content

Commit 7d7be28

Browse files
committed
fix: sun
Signed-off-by: suwhang-cisco <suwhang@cisco.com>
1 parent 5ec9c73 commit 7d7be28

File tree

2 files changed

+83
-101
lines changed

2 files changed

+83
-101
lines changed

.github/workflows/helm-pre-release.yml

Lines changed: 26 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
name: "[Pre-Release] Helm Chart"
22
description: "Publish pre-release Helm charts"
33

4-
# Triggered when [CI][Helm] Auto-bump Chart Versions workflow completes
54
on:
6-
workflow_run:
7-
workflows: ["[CI][Helm] Auto-bump Chart Versions"]
8-
types:
9-
- completed
10-
branches:
11-
- main
12-
- 'prebuild/**'
5+
# Called directly from helm-rc-version-bump workflow
6+
workflow_call:
7+
inputs:
8+
pr_number:
9+
description: 'PR number to publish pre-release for'
10+
required: true
11+
type: number
12+
new_commit:
13+
description: 'Whether a new commit was made by version bump'
14+
required: false
15+
type: boolean
16+
default: false
1317

1418
permissions:
1519
contents: read
@@ -21,47 +25,18 @@ jobs:
2125
publish-pre-release:
2226
name: Publish Pre-release Helm Chart
2327
runs-on: ubuntu-latest
24-
# Only run if the triggering workflow succeeded
25-
if: github.event.workflow_run.conclusion == 'success'
28+
# Skip if a new commit was made (will re-run on next trigger)
29+
if: ${{ !inputs.new_commit }}
2630

2731
steps:
28-
- name: 📥 Download version bump status artifact
29-
uses: actions/download-artifact@v7
30-
with:
31-
name: version-bump-status
32-
run-id: ${{ github.event.workflow_run.id }}
33-
github-token: ${{ secrets.GITHUB_TOKEN }}
34-
35-
- name: 📋 Read version bump status
32+
- name: 📋 Set PR info from inputs
3633
id: bump-status
3734
run: |
38-
if [[ -f "version-bump-status.txt" ]]; then
39-
echo "📋 Version bump status:"
40-
cat version-bump-status.txt
41-
42-
# Parse the status file
43-
NEW_COMMIT=$(grep "^new_commit=" version-bump-status.txt | cut -d'=' -f2)
44-
PR_NUMBER=$(grep "^pr_number=" version-bump-status.txt | cut -d'=' -f2)
45-
HEAD_SHA=$(grep "^head_sha=" version-bump-status.txt | cut -d'=' -f2)
46-
47-
echo "new_commit=$NEW_COMMIT" >> $GITHUB_OUTPUT
48-
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
49-
echo "head_sha=$HEAD_SHA" >> $GITHUB_OUTPUT
50-
51-
if [[ "$NEW_COMMIT" == "true" ]]; then
52-
echo "🔄 Version bump workflow made a new commit - skipping pre-release"
53-
echo "skip=true" >> $GITHUB_OUTPUT
54-
else
55-
echo "✅ No new commit from version bump - proceeding with pre-release"
56-
echo "skip=false" >> $GITHUB_OUTPUT
57-
fi
58-
else
59-
echo "⚠️ No version bump status file found"
60-
echo "skip=false" >> $GITHUB_OUTPUT
61-
fi
35+
echo "pr_number=${{ inputs.pr_number }}" >> $GITHUB_OUTPUT
36+
echo "skip=false" >> $GITHUB_OUTPUT
37+
echo "📋 Processing PR #${{ inputs.pr_number }}"
6238
6339
- name: 🔍 Get PR details
64-
if: steps.bump-status.outputs.skip != 'true'
6540
id: pr-info
6641
uses: actions/github-script@v8
6742
with:
@@ -88,49 +63,13 @@ jobs:
8863
console.log(`Head SHA: ${pr.head.sha}`);
8964
console.log(`Labels: ${pr.labels.map(l => l.name).join(', ')}`);
9065
91-
- name: 🔍 Check if pre-release should run
92-
if: steps.bump-status.outputs.skip != 'true'
93-
id: should-run
94-
run: |
95-
HEAD_REF="${{ steps.pr-info.outputs.head_ref }}"
96-
HEAD_REPO="${{ steps.pr-info.outputs.head_repo_full_name }}"
97-
LABELS="${{ steps.pr-info.outputs.labels }}"
98-
REPO="${{ github.repository }}"
99-
100-
echo "🔍 Checking pre-release conditions..."
101-
echo " Branch: $HEAD_REF"
102-
echo " Repo: $HEAD_REPO"
103-
echo " Labels: $LABELS"
104-
105-
SHOULD_RUN=false
106-
107-
# Check for prebuild/ branch from same repo
108-
if [[ "$HEAD_REPO" == "$REPO" && "$HEAD_REF" == prebuild/* ]]; then
109-
echo "✅ Matched: prebuild/ branch from same repo"
110-
SHOULD_RUN=true
111-
fi
112-
113-
# Check for helm-prerelease label
114-
if [[ "$LABELS" == *"helm-prerelease"* ]]; then
115-
echo "✅ Matched: helm-prerelease label"
116-
SHOULD_RUN=true
117-
fi
118-
119-
echo "should_run=$SHOULD_RUN" >> $GITHUB_OUTPUT
120-
121-
if [[ "$SHOULD_RUN" != "true" ]]; then
122-
echo "ℹ️ Skipping pre-release - conditions not met"
123-
fi
124-
12566
- name: 📥 Checkout repository
126-
if: steps.bump-status.outputs.skip != 'true' && steps.should-run.outputs.should_run == 'true'
12767
uses: actions/checkout@v6
12868
with:
12969
ref: ${{ steps.pr-info.outputs.head_sha }}
13070
fetch-depth: 0
13171

13272
- name: 🔍 Check if chart versions are bumped
133-
if: steps.bump-status.outputs.skip != 'true' && steps.should-run.outputs.should_run == 'true'
13473
id: version-check
13574
run: |
13675
git fetch origin main
@@ -185,18 +124,18 @@ jobs:
185124
fi
186125
187126
- name: ⚙️ Set up Helm
188-
if: steps.bump-status.outputs.skip != 'true' && steps.should-run.outputs.should_run == 'true' && steps.version-check.outputs.skip != 'true'
127+
if: steps.version-check.outputs.skip != 'true'
189128
uses: azure/setup-helm@v4
190129
with:
191130
version: v3.14.0
192131

193132
- name: 🔐 Login to GHCR
194-
if: steps.bump-status.outputs.skip != 'true' && steps.should-run.outputs.should_run == 'true' && steps.version-check.outputs.skip != 'true'
133+
if: steps.version-check.outputs.skip != 'true'
195134
run: |
196135
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
197136
198137
- name: 🔍 Detect Changed Charts
199-
if: steps.bump-status.outputs.skip != 'true' && steps.should-run.outputs.should_run == 'true' && steps.version-check.outputs.skip != 'true'
138+
if: steps.version-check.outputs.skip != 'true'
200139
id: detect
201140
run: |
202141
# Detect which charts have changes (excluding Chart.lock only changes)
@@ -236,7 +175,7 @@ jobs:
236175
echo "ai-platform-changed=$AI_PLATFORM_CHANGED" >> $GITHUB_OUTPUT
237176
238177
- name: 🏷️ Generate Pre-release Versions
239-
if: steps.bump-status.outputs.skip != 'true' && steps.should-run.outputs.should_run == 'true' && steps.version-check.outputs.skip != 'true'
178+
if: steps.version-check.outputs.skip != 'true'
240179
id: version
241180
run: |
242181
# Get branch name and remove 'prebuild/' prefix if present
@@ -284,7 +223,7 @@ jobs:
284223
fi
285224
286225
- name: 📦 Package rag-stack Chart
287-
if: steps.bump-status.outputs.skip != 'true' && steps.should-run.outputs.should_run == 'true' && steps.version-check.outputs.skip != 'true' && steps.detect.outputs.rag-stack-changed == 'true'
226+
if: steps.version-check.outputs.skip != 'true' && steps.detect.outputs.rag-stack-changed == 'true'
288227
run: |
289228
echo "📦 Packaging rag-stack..."
290229
@@ -300,7 +239,7 @@ jobs:
300239
echo "✅ rag-stack packaged successfully"
301240
302241
- name: 📦 Package ai-platform-engineering Chart
303-
if: steps.bump-status.outputs.skip != 'true' && steps.should-run.outputs.should_run == 'true' && steps.version-check.outputs.skip != 'true' && steps.detect.outputs.ai-platform-changed == 'true'
242+
if: steps.version-check.outputs.skip != 'true' && steps.detect.outputs.ai-platform-changed == 'true'
304243
run: |
305244
echo "📦 Packaging ai-platform-engineering..."
306245
@@ -345,7 +284,7 @@ jobs:
345284
echo "✅ ai-platform-engineering packaged successfully with all dependencies"
346285
347286
- name: 🚀 Push Pre-release Charts to GHCR
348-
if: steps.bump-status.outputs.skip != 'true' && steps.should-run.outputs.should_run == 'true' && steps.version-check.outputs.skip != 'true'
287+
if: steps.version-check.outputs.skip != 'true'
349288
run: |
350289
REGISTRY="oci://ghcr.io/${{ github.repository_owner }}/pre-release-helm-charts"
351290
@@ -363,7 +302,7 @@ jobs:
363302
done
364303
365304
- name: 💬 Comment on PR
366-
if: steps.bump-status.outputs.skip != 'true' && steps.should-run.outputs.should_run == 'true' && steps.version-check.outputs.skip != 'true'
305+
if: steps.version-check.outputs.skip != 'true'
367306
uses: actions/github-script@v8
368307
with:
369308
script: |

.github/workflows/helm-rc-version-bump.yml

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ on:
1414

1515
permissions:
1616
contents: write
17-
pull-requests: read
17+
pull-requests: write
18+
packages: write
19+
actions: read
1820

1921
jobs:
2022
auto-bump-versions:
2123
name: Auto-bump Chart Versions
2224
runs-on: ubuntu-latest
2325
# Don't run on commits made by this workflow (avoid infinite loop)
2426
if: github.actor != 'github-actions[bot]'
27+
outputs:
28+
new_commit: ${{ steps.status.outputs.new_commit }}
29+
should_prerelease: ${{ steps.prerelease-check.outputs.should_run }}
2530
steps:
2631
- name: 📥 Checkout repository
2732
uses: actions/checkout@v6.0.1
@@ -424,21 +429,59 @@ jobs:
424429
# Determine if a new commit was made
425430
if [[ "${{ steps.commit.outputs.committed }}" == "true" ]]; then
426431
echo "new_commit=true" >> $GITHUB_OUTPUT
427-
echo "🔄 New commit was made - downstream workflows should skip"
432+
echo "🔄 New commit was made - pre-release will run on next trigger"
428433
else
429434
echo "new_commit=false" >> $GITHUB_OUTPUT
430-
echo "✅ No new commit - downstream workflows can proceed"
435+
echo "✅ No new commit - pre-release can proceed"
431436
fi
432437
433-
# Write status file for artifact
434-
mkdir -p ${{ runner.temp }}/status
435-
echo "new_commit=${{ steps.commit.outputs.committed == 'true' && 'true' || 'false' }}" > "${{ runner.temp }}/status/version-bump-status.txt"
436-
echo "pr_number=${{ github.event.pull_request.number }}" >> "${{ runner.temp }}/status/version-bump-status.txt"
437-
echo "head_sha=${{ github.event.pull_request.head.sha }}" >> "${{ runner.temp }}/status/version-bump-status.txt"
438+
- name: 🔍 Check if pre-release should run
439+
id: prerelease-check
440+
if: github.event_name == 'pull_request'
441+
env:
442+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
443+
run: |
444+
HEAD_REF="${{ github.head_ref }}"
445+
REPO="${{ github.repository }}"
446+
PR_NUMBER="${{ github.event.pull_request.number }}"
438447
439-
- name: 📦 Save commit status artifact
440-
uses: actions/upload-artifact@v6
441-
with:
442-
name: version-bump-status
443-
path: ${{ runner.temp }}/status/version-bump-status.txt
444-
retention-days: 1
448+
echo "🔍 Checking pre-release conditions..."
449+
echo " Branch: $HEAD_REF"
450+
echo " PR: #$PR_NUMBER"
451+
452+
SHOULD_RUN=false
453+
454+
# Check for prebuild/ branch
455+
if [[ "$HEAD_REF" == prebuild/* ]]; then
456+
echo "✅ Matched: prebuild/ branch"
457+
SHOULD_RUN=true
458+
fi
459+
460+
# Check for helm-prerelease label
461+
LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name' 2>/dev/null | tr '\n' ',' || echo "")
462+
echo " Labels: $LABELS"
463+
464+
if [[ "$LABELS" == *"helm-prerelease"* ]]; then
465+
echo "✅ Matched: helm-prerelease label"
466+
SHOULD_RUN=true
467+
fi
468+
469+
echo "should_run=$SHOULD_RUN" >> $GITHUB_OUTPUT
470+
471+
if [[ "$SHOULD_RUN" != "true" ]]; then
472+
echo "ℹ️ Skipping pre-release - conditions not met (need prebuild/ branch or helm-prerelease label)"
473+
fi
474+
475+
# Call pre-release workflow for PRs on prebuild/ branches or with helm-prerelease label
476+
helm-pre-release:
477+
name: Publish Pre-release Helm Charts
478+
needs: auto-bump-versions
479+
if: |
480+
github.event_name == 'pull_request' &&
481+
needs.auto-bump-versions.outputs.should_prerelease == 'true' &&
482+
needs.auto-bump-versions.outputs.new_commit != 'true'
483+
uses: ./.github/workflows/helm-pre-release.yml
484+
with:
485+
pr_number: ${{ github.event.pull_request.number }}
486+
new_commit: ${{ needs.auto-bump-versions.outputs.new_commit == 'true' }}
487+
secrets: inherit

0 commit comments

Comments
 (0)