|
| 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 |
0 commit comments