Skip to content

Commit 77215f4

Browse files
committedJun 9, 2025·
Create various files to automate the release of notebooks with the github action call: Notebooks Release
1 parent 858b1b8 commit 77215f4

File tree

3 files changed

+341
-2
lines changed

3 files changed

+341
-2
lines changed
 

‎.github/workflows/notebooks-digest-updater.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,28 @@ on: # yamllint disable-line rule:truthy
88
branch:
99
required: false
1010
description: "Optional: Provide branch name"
11+
type: string
1112
user-hash:
1213
required: false
1314
description: "Optional: Specify a Git hash (it should exists on the branch history)"
15+
type: string
16+
workflow_call:
17+
inputs:
18+
branch:
19+
required: false
20+
description: "Optional: Provide branch name"
21+
type: string
22+
user-hash:
23+
required: false
24+
description: "Optional: Specify a Git hash (it should exists on the branch history)"
25+
type: string
1426

1527
env:
16-
USER_HASH: ${{ github.event.inputs.user-hash }}
28+
USER_HASH: ${{ inputs.user-hash }}
1729
REPO_ORG: ${{ github.repository_owner }}
1830
REPO_NAME: 'notebooks'
1931
TMP_BRANCH: tmp-digest-sync-${{ github.run_id }}
20-
BRANCH_NAME: ${{ github.event.inputs.branch || 'main' }}
32+
BRANCH_NAME: ${{ inputs.branch || 'main' }}
2133

2234
jobs:
2335
update-images:
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
---
2+
name: Notebooks Release
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Release tag for the notebooks release'
8+
required: true
9+
default: 'v1.32.0'
10+
type: string
11+
release_name:
12+
description: 'Name of the release'
13+
required: true
14+
default: '2025a'
15+
type: string
16+
buildconfigs_version:
17+
description: 'Version to update the BuildConfigs to (if applicable)'
18+
required: false
19+
type: string
20+
update_buildconfigs:
21+
description: 'Update BuildConfigs for CUDA RStudio and RStudio'
22+
required: true
23+
default: 'true'
24+
type: boolean
25+
branch:
26+
description: "Optional: Provide branch name"
27+
required: false
28+
type: string
29+
user-hash:
30+
description: "Optional: Specify a Git hash (it should exists on the branch history)"
31+
required: false
32+
type: string
33+
34+
env:
35+
RELEASE_TAG: ${{ github.event.inputs.tag }}
36+
RELEASE_NAME: ${{ github.event.inputs.release_name }}
37+
BRANCH: ${{ github.event.inputs.branch }}
38+
USER_HASH: ${{ github.event.inputs.user-hash }}
39+
REPO_OWNER: opendatahub-io
40+
REPO_NAME: notebooks
41+
VERSION: ${{ github.event.inputs.buildconfigs_version}}
42+
43+
jobs:
44+
#1. Update the params.env and commit.env files with new SHAs
45+
Update-manifests:
46+
uses: opendatahub-io/notebooks/.github/workflows/notebooks-digest-updater.yaml@main
47+
with:
48+
branch: ${{ github.event.inputs.branch }}
49+
user-hash: ${{ github.event.inputs.user_hash }}
50+
51+
# 2. Check if the Manifest PR is merged
52+
Manifests-merged:
53+
needs: Update-manifests
54+
runs-on: ubuntu-latest
55+
outputs:
56+
pr_merged_m: ${{ steps.check_pr.outputs.pr_merged_m }}
57+
steps:
58+
- name: Check out repository
59+
uses: actions/checkout@v4
60+
with:
61+
fetch-depth: 0
62+
63+
- name: Check if PR is merged
64+
id: check_pr
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
run: |
68+
# PR to look for
69+
PR_TITLE="[Updater Action] Update Notebook and Runtime Images as well as the Commits With New SHAs"
70+
71+
#Fetch matching PRs
72+
PR_NUMBER=$(gh pr list --repo "$REPO_OWNER/$REPO_NAME" --state all --search "$PR_TITLE" --json number,title | jq -r '.[0].number')
73+
echo "PR Numbers: $PR_NUMBER"
74+
75+
if [ -z "$PR_NUMBER" ]; then
76+
echo "No PR found with title: $PR_TITLE"
77+
exit 1
78+
fi
79+
80+
MAX_ATTEMPTS=30
81+
for (( i=1; i<=MAX_ATTEMPTS; i++ )); do
82+
echo "Checking if PR #$PR_NUMBER is merged (Attempt $i/$MAX_ATTEMPTS)..."
83+
for (( j=1; i<=600; j++ )); do
84+
PR_STATE=$(gh pr view --repo "$REPO_OWNER/$REPO_NAME" $PR_NUMBER --json mergedAt --jq '.mergedAt')
85+
86+
if [ "$PR_STATE" = "null" ] || [ -z "$PR_STATE" ]; then
87+
echo "PR #$PR_NUMBER is not merged yet. Waiting..."
88+
sleep 1
89+
else
90+
echo "PR #$PR_NUMBER is merged!"
91+
echo "pr_merged_m=true" >> $GITHUB_ENV
92+
echo "pr_merged_m=true" >> $GITHUB_OUTPUT
93+
exit 0
94+
fi
95+
done
96+
done
97+
98+
echo "Timed out waiting for PR #$PR_NUMBER to be merged."
99+
echo "pr_merged_m=false" >> $GITHUB_ENV
100+
echo "pr_merged_m=false" >> $GITHUB_OUTPUT
101+
exit 1
102+
103+
# 3. Update the BuildConfigs for CUDA RStudio and RStudio
104+
Update-buildConfigs:
105+
if: github.event.inputs.update_buildconfigs == 'true'
106+
uses: opendatahub-io/notebooks/.github/workflows/update-buildconfigs.yaml@main
107+
with:
108+
branch: ${{ github.event.inputs.branch }}
109+
version: ${{ github.event.inputs.buildconfigs_version }}
110+
111+
# 4. Check if the BuildConfigs PR is merged
112+
BuildConfigs-merged:
113+
if: github.event.inputs.update_buildconfigs == 'true'
114+
needs: Update-buildConfigs
115+
runs-on: ubuntu-latest
116+
outputs:
117+
pr_merged_b: ${{ steps.check_pr.outputs.pr_merged_b }}
118+
steps:
119+
- name: Check out repository
120+
uses: actions/checkout@v4
121+
with:
122+
fetch-depth: 0
123+
124+
- name: Check if PR is merged
125+
id: check_pr
126+
env:
127+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128+
run: |
129+
# PR to look for
130+
PR_TITLE="[Updater Action] Update BuildConfigs for CUDA RStudio and RStudio"
131+
132+
#Fetch matching PRs
133+
PR_NUMBER=$(gh pr list --repo "$REPO_OWNER/$REPO_NAME" --state all --search "$PR_TITLE" --json number,title | jq -r '.[0].number')
134+
echo "PR Numbers: $PR_NUMBER"
135+
136+
if [ -z "$PR_NUMBER" ]; then
137+
echo "No PR found with title: $PR_TITLE"
138+
exit 1
139+
fi
140+
141+
MAX_ATTEMPTS=30
142+
for (( i=1; i<=MAX_ATTEMPTS; i++ )); do
143+
echo "Checking if PR #$PR_NUMBER is merged (Attempt $i/$MAX_ATTEMPTS)..."
144+
for (( j=1; i<=600; j++ )); do
145+
PR_STATE=$(gh pr view --repo "$REPO_OWNER/$REPO_NAME" $PR_NUMBER --json mergedAt --jq '.mergedAt')
146+
147+
if [ "$PR_STATE" = "null" ] || [ -z "$PR_STATE" ]; then
148+
echo "PR #$PR_NUMBER is not merged yet. Waiting..."
149+
sleep 1
150+
else
151+
echo "PR #$PR_NUMBER is merged!"
152+
echo "pr_merged_b=true" >> $GITHUB_ENV
153+
echo "pr_merged_b=true" >> $GITHUB_OUTPUT
154+
exit 0
155+
fi
156+
done
157+
done
158+
159+
echo "Timed out waiting for PR #$PR_NUMBER to be merged."
160+
echo "pr_merged_b=false" >> $GITHUB_ENV
161+
echo "pr_merged_b=false" >> $GITHUB_OUTPUT
162+
exit 1
163+
164+
# 5. Generate the release with BuildConfigs if needed
165+
Generate-release_with_buildconfigs:
166+
needs: [Update-manifests, Manifests-merged, Update-buildConfigs, BuildConfigs-merged]
167+
if: needs.Manifests-merged.outputs.pr_merged_m == 'true' && needs.BuildConfigs-merged.outputs.pr_merged_b == 'true' && github.event.inputs.update_buildconfigs == 'true'
168+
runs-on: ubuntu-latest
169+
steps:
170+
- name: Check out repository
171+
uses: actions/checkout@v4
172+
with:
173+
fetch-depth: 0
174+
- name: Invoke Script to handle creating a release
175+
env:
176+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
177+
working-directory: ${{env.GITHUB_WORKSPACE}}
178+
run: |
179+
gh release create "$RELEASE_TAG" --title="$RELEASE_NAME-$RELEASE_TAG" --generate-notes --target $BRANCH
180+
181+
# 6. Generate the release without BuildConfigs
182+
Generate-release:
183+
needs: [Update-manifests, Manifests-merged]
184+
if: needs.Manifests-merged.outputs.pr_merged_m == 'true' && github.event.inputs.update_buildconfigs == 'false'
185+
runs-on: ubuntu-latest
186+
steps:
187+
- name: Check out repository
188+
uses: actions/checkout@v4
189+
with:
190+
fetch-depth: 0
191+
192+
- name: Create Source Branch
193+
run: |
194+
git checkout -b $SOURCE_BRANCH
195+
git push origin $SOURCE_BRANCH
196+
197+
- name: create pull request
198+
run: |
199+
gh pr create -B $SOURCE_BRANCH -H $TARGET_BRANCH --title 'Merge branch_to_merge into base_branch' --body 'Created by Github action'
200+
env:
201+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
202+
working-directory: ${{env.GITHUB_WORKSPACE}}
203+
run: |
204+
gh release create "$RELEASE_TAG" --title="$RELEASE_NAME-$RELEASE_TAG" --generate-notes --target $BRANCH
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# The aim of this GitHub workflow is to update the cuda-rstudio-buildconfig.yaml and rstudio-buildconfig.yaml
2+
# If No version is provided, it will update the BuildConfigs to the next version by incrementing the minor version number by 1.
3+
---
4+
name: Update BuildConfigs
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
branch:
9+
description: "Optional: Provide branch name"
10+
required: false
11+
type: string
12+
version:
13+
description: "Optional: Provide version to update BuildConfigs to"
14+
required: false
15+
type: string
16+
workflow_call:
17+
inputs:
18+
branch:
19+
required: false
20+
type: string
21+
version:
22+
required: false
23+
type: string
24+
env:
25+
TMP_BRANCH: tmp-verify-${{ github.run_id }}
26+
BRANCH: ${{ inputs.branch || 'main' }}
27+
VERSION: ${{ inputs.version }}
28+
29+
jobs:
30+
buidConfigs:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Check out repository
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Configure Git
39+
run: |
40+
git config user.name "GitHub Actions"
41+
git config user.email "github-actions[bot]@users.noreply.github.com"
42+
43+
- name: Create Target Branch
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
working-directory: ${{env.GITHUB_WORKSPACE}}
47+
run: |
48+
git checkout -b $TMP_BRANCH
49+
git push origin $TMP_BRANCH
50+
51+
52+
- name: Update BuildConfig
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
working-directory: ${{env.GITHUB_WORKSPACE}}
56+
run: |
57+
if [[ -z "$VERSION" ]]; then
58+
while IFS= read -r line; do
59+
if [[ "$line" == *"ref: rhoai-"* ]]; then
60+
numstrc=${line#*2.}
61+
numc=$(expr "$numstrc" + 1)
62+
echo " ref: rhoai-2.$numc" >> tmp.yaml
63+
else
64+
echo "$line" >> tmp.yaml
65+
fi
66+
done < ./manifests/base/cuda-rstudio-buildconfig.yaml
67+
cat tmp.yaml > ./manifests/base/cuda-rstudio-buildconfig.yaml
68+
rm tmp.yaml
69+
while IFS= read -r line; do
70+
if [[ "$line" == *"ref: rhoai-"* ]]; then
71+
numstr=${line#*2.}
72+
num=$(expr "$numstr" + 1)
73+
echo " ref: rhoai-2.$num" >> tmp.yaml
74+
else
75+
echo "$line" >> tmp.yaml
76+
fi
77+
done < ./manifests/base/rstudio-buildconfig.yaml
78+
cat tmp.yaml > ./manifests/base/rstudio-buildconfig.yaml
79+
rm tmp.yaml
80+
else
81+
while IFS= read -r line; do
82+
if [[ "$line" == *"ref: rhoai-"* ]]; then
83+
echo " ref: rhoai-$VERSION" >> tmp.yaml
84+
else
85+
echo "$line" >> tmp.yaml
86+
fi
87+
done < ./manifests/base/cuda-rstudio-buildconfig.yaml
88+
cat tmp.yaml > ./manifests/base/cuda-rstudio-buildconfig.yaml
89+
rm tmp.yaml
90+
while IFS= read -r line; do
91+
if [[ "$line" == *"ref: rhoai-"* ]]; then
92+
echo " ref: rhoai-$VERSION" >> tmp.yaml
93+
else
94+
echo "$line" >> tmp.yaml
95+
fi
96+
done < ./manifests/base/rstudio-buildconfig.yaml
97+
cat tmp.yaml > ./manifests/base/rstudio-buildconfig.yaml
98+
rm tmp.yaml
99+
fi
100+
101+
102+
- name: Add Files and Commit Changes
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
working-directory: ${{env.GITHUB_WORKSPACE}}
106+
run: |
107+
git add ./manifests/base/cuda-rstudio-buildconfig.yaml
108+
git add ./manifests/base/rstudio-buildconfig.yaml
109+
git commit -m "Update BuildConfigs for CUDA RStudio and RStudio"
110+
git push origin $TMP_BRANCH
111+
112+
- name: Create Pull Request
113+
run: |
114+
gh pr create -B $BRANCH -H $TMP_BRANCH --title "$PR_TITLE" --body "$PR_BODY"
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
PR_TITLE: "[Updater Action] Update BuildConfigs for CUDA RStudio and RStudio"
118+
PR_BODY: |
119+
:rocket: This is an automated Pull Request.
120+
Created by `/.github/workflows/update-buildconfigs.yaml`
121+
- `manifests/base/cuda-rstudio-buildconfig.yaml` File that points to the latest CUDA RStudio version
122+
- `manifests/base/rstudio-buildconfig.yaml` File that points to the latest RStudio version
123+

0 commit comments

Comments
 (0)