forked from kubeflow/kubeflow
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kubeflow sync release pipeline #469
Merged
openshift-merge-bot
merged 8 commits into
opendatahub-io:main
from
atheo89:RHOAIENG-15453
Nov 28, 2024
+308
−110
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4407906
Modify notebook-controller-images-updater gha to be callable action a…
atheo89 828e603
Update sync branches action to automerge the changes to the target br…
atheo89 9686cd1
Introduce create-release gha used as mockup to unblock the developmen…
atheo89 c8147db
Introduce kubeflow-release action that orchestrates all previous manu…
atheo89 0fde48c
little tweeks
atheo89 5b9d718
fix typos
atheo89 1c04397
Add an option create-new-release to create or not release, for extra …
atheo89 3366327
Apply suggestions from the review
atheo89 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
name: Create Release | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
input_var: | ||
description: "Say Hi!" | ||
required: true | ||
workflow_call: | ||
inputs: | ||
input_var: | ||
type: string | ||
required: true | ||
|
||
env: | ||
INPUT_VAR: ${{ inputs.input_var }} | ||
|
||
jobs: | ||
say-hello: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Say Hello | ||
run: echo "${{ env.INPUT_VAR }}, World!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
--- | ||
name: Kubeflow Release Pipeline | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
create-new-release: | ||
description: "Create a new release?" | ||
required: true | ||
default: "true" | ||
env: | ||
CREATE_NEW_RELEASE: ${{ inputs.create-new-release }} | ||
REPO_OWNER: opendatahub-io | ||
REPO_NAME: kubeflow | ||
BRANCH_NAME: v1.9-branch | ||
|
||
jobs: | ||
# 1. Sync changes to opendatahub:v1.9-branch from opendatahub:main | ||
sync-main-to-release-branch: | ||
uses: opendatahub-io/kubeflow/.github/workflows/sync-branches.yaml@main | ||
with: | ||
source: "main" | ||
target: "v1.9-branch" | ||
|
||
# 2. Poll for images to be available on quay.io the readiness of the images usually takes ~10 mins | ||
wait-images-to-build-on-quay: | ||
atheo89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
needs: sync-main-to-release-branch | ||
runs-on: ubuntu-latest | ||
outputs: | ||
images_ready: ${{ steps.check-images.outputs.images_ready }} | ||
steps: | ||
- name: Poll for images availability | ||
id: check-images | ||
run: | | ||
atheo89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Install required tools | ||
sudo apt-get update | ||
sudo apt-get install -y skopeo jq curl | ||
|
||
# Get the latest Git hash from the target branch | ||
PAYLOAD=$(curl --silent -H 'Accept: application/vnd.github.v4.raw' https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/commits?sha=$BRANCH_NAME&per_page=1) | ||
GIT_HASH=$(echo "$PAYLOAD" | jq -r '.[0].sha' | cut -c 1-7) | ||
atheo89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo "GIT_HASH=$GIT_HASH" | ||
|
||
# Images to check | ||
IMAGES=( | ||
"quay.io/opendatahub/kubeflow-notebook-controller:1.9-${GIT_HASH}" | ||
"quay.io/opendatahub/odh-notebook-controller:1.9-${GIT_HASH}" | ||
) | ||
# Poll for image readiness total timeout=15m | ||
MAX_ATTEMPTS=10 | ||
SLEEP_DURATION=90 | ||
for image in "${IMAGES[@]}"; do | ||
for (( i=1; i<=MAX_ATTEMPTS; i++ )); do | ||
echo "Checking availability of $image (Attempt $i/$MAX_ATTEMPTS)..." | ||
if skopeo inspect docker://$image &>/dev/null; then | ||
echo "$image is available!" | ||
break | ||
fi | ||
if [[ $i -eq $MAX_ATTEMPTS ]]; then | ||
echo "Timed out waiting for $image to become available." | ||
exit 1 | ||
fi | ||
sleep $SLEEP_DURATION | ||
done | ||
done | ||
echo "images_ready=true" >> $GITHUB_ENV | ||
echo "images_ready=true" >> $GITHUB_OUTPUT | ||
|
||
- name: Images are ready | ||
if: ${{ env.images_ready == 'true' }} | ||
run: echo "All images are ready. Proceeding to the next step." | ||
|
||
# 3. Once Images are availble then updates the notebook controllers’ image tags | ||
update-release-images: | ||
needs: wait-images-to-build-on-quay | ||
if: ${{ needs.wait-images-to-build-on-quay.outputs.images_ready == 'true' }} | ||
uses: opendatahub-io/kubeflow/.github/workflows/notebook-controller-images-updater.yaml@main | ||
with: | ||
branch-name: "v1.9-branch" | ||
organization: "opendatahub-io" | ||
generate-pr: "true" | ||
|
||
# 4. Check PR merged status | ||
check-pr-merged: | ||
needs: update-release-images | ||
runs-on: ubuntu-latest | ||
outputs: | ||
pr_merged: ${{ steps.check.outputs.pr_merged }} | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check if the PR is merged | ||
id: check | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
# PR to look for | ||
PR_TITLE="[GHA-${{ github.run_id }}]" | ||
# Fetch matching PRs | ||
gh pr list --repo atheo89/kubeflow --state all --search "$PR_TITLE" --json number,title > pr_list.json | ||
atheo89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Extract the PR number | ||
PR_NUMBER=$(jq -r '.[0].number' pr_list.json) | ||
echo "PR number: $PR_NUMBER" | ||
|
||
if [ -z "$PR_NUMBER" ]; then | ||
echo "No matching PR found." | ||
exit 1 | ||
fi | ||
|
||
# Polling loop to wait for the PR to be merged total timeout=1h | ||
MAX_ATTEMPTS=10 | ||
SLEEP_DURATION=360 | ||
|
||
for (( i=1; i<=MAX_ATTEMPTS; i++ )); do | ||
echo "Checking if PR #$PR_NUMBER is merged (Attempt $i/$MAX_ATTEMPTS)..." | ||
PR_STATE=$(gh pr view --repo atheo89/kubeflow $PR_NUMBER --json mergedAt --jq '.mergedAt') | ||
atheo89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if [ "$PR_STATE" = "null" ] || [ -z "$PR_STATE" ]; then | ||
echo "PR #$PR_NUMBER is not merged yet. Waiting..." | ||
sleep $SLEEP_DURATION | ||
else | ||
echo "PR #$PR_NUMBER is merged!" | ||
echo "pr_merged=true" >> $GITHUB_ENV | ||
echo "pr_merged=true" >> $GITHUB_OUTPUT | ||
exit 0 | ||
fi | ||
done | ||
|
||
echo "Timed out waiting for PR #$PR_NUMBER to be merged." | ||
echo "pr_merged=false" >> $GITHUB_ENV | ||
echo "pr_merged=false" >> $GITHUB_OUTPUT | ||
exit 1 | ||
|
||
# 5. Create a release (Mock-Up workflow it will be fullfill by RHOAIENG-15391) | ||
create-release: | ||
needs: [update-release-images, check-pr-merged] | ||
if: ${{ needs.check-pr-merged.outputs.pr_merged == 'true' && inputs.create-new-release == 'true' }} | ||
uses: opendatahub-io/kubeflow/.github/workflows/create-release.yaml@main | ||
with: | ||
input_var: "Eyo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @andyatmiami! This is only a mockup gha, it prints a
Eyo, World
for now 🤣 It used to work on the logic of thekubeflow release
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, fwiw... and I'm happy to change what I did with the
create release
PoC I did.. but I was condititioning the release creation logic on the push of a tag matching a specific pattern...So it wouldn't need to be explicitly invoked here.. but if that "trigger off tag" won't work for reasons I am not appreciating - I am happy to adapt!