-
Notifications
You must be signed in to change notification settings - Fork 61
add step to sync ODH notebooks with Codeflare-SDK release #460
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
Merged
openshift-merge-bot
merged 2 commits into
project-codeflare:main
from
abhijeet-dhumal:add-odh-sync
Feb 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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,116 @@ | ||
# The aim of this GitHub workflow is to update the pipfile to sync with Codeflare-SDK release. | ||
name: Sync with codeflare-sdk release | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
upstream-repository-organization: | ||
required: true | ||
description: "Owner of target upstream notebooks repository used to open a PR against" | ||
default: "opendatahub-io" | ||
|
||
codeflare-repository-organization: | ||
required: true | ||
description: "Owner of origin notebooks repository used to open a PR" | ||
default: "project-codeflare" | ||
|
||
codeflare_sdk_release_version: | ||
required: true | ||
description: "Provide version of the Codeflare-SDK release" | ||
|
||
env: | ||
BRANCH_NAME: main | ||
CODEFLARE_RELEASE_VERSION: ${{ github.event.inputs.codeflare_sdk_release_version }} | ||
UPDATER_BRANCH: odh-sync-updater-${{ github.run_id }} | ||
UPSTREAM_OWNER: ${{ github.event.inputs.upstream-repository-organization }} | ||
REPO_OWNER: ${{ github.event.inputs.codeflare-repository-organization }} | ||
REPO_NAME: notebooks | ||
GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ env.BRANCH_NAME }} | ||
|
||
- name: Clone repository and Sync | ||
run: | | ||
git clone https://x-access-token:${GITHUB_TOKEN}@github.com/$REPO_OWNER/$REPO_NAME.git $REPO_NAME | ||
cd $REPO_NAME | ||
git remote add upstream https://github.com/$UPSTREAM_OWNER/$REPO_NAME.git | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "codeflare-machine-account" | ||
git remote -v | ||
git pull upstream main && git push origin main | ||
|
||
- name: Setup Python environment | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: | | ||
3.8 | ||
3.9 | ||
|
||
- name: Install pipenv | ||
run: pip install pipenv | ||
|
||
- name: Update Pipfiles in accordance with Codeflare-SDK latest release | ||
run: | | ||
# list all Pipfile paths having Codeflare-SDK listed | ||
paths+=($(grep -rl 'codeflare-sdk = "~=.*"')) | ||
# Extracting only directories from file paths, excluding a `.gitworkflow` directory | ||
directories=() | ||
exclude_directories=( | ||
".git/objects/pack" | ||
".github/workflows/", | ||
) | ||
for path in "${paths[@]}"; do | ||
current_dir=$(dirname "$path") | ||
#Check if current_dir is not in exclude_directories list | ||
if [[ ! "${exclude_directories[@]}" =~ "$current_dir" ]]; then | ||
#Check if Pipfile exists in current_dir | ||
if [ -f "$current_dir/Pipfile" ];then | ||
directories+=("$current_dir") | ||
fi | ||
fi | ||
done | ||
# Remove duplicates | ||
directories=($(echo "${directories[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')) | ||
# Print the directories for verification | ||
echo "Directories (Start updating Pipfile in these below directories in accordance with Codeflare-SDK latest release):" | ||
for dir in "${directories[@]}"; do | ||
echo "- $dir" | ||
done | ||
# iterate over the directories and update Pipfile | ||
counter=0 | ||
total=${#directories[@]} | ||
for dir in "${directories[@]}"; do | ||
counter=$((counter+1)) | ||
echo "--Processing directory $counter '$dir' of total $total" | ||
cd "$dir" && pipenv install codeflare-sdk~="${CODEFLARE_RELEASE_VERSION}" && pipenv --rm && cd - | ||
echo "$((total-counter)) directories remaining.." | ||
done | ||
|
||
- name: Push changes | ||
run: | | ||
cd $REPO_NAME | ||
git add . && git status && git checkout -b ${{ env.UPDATER_BRANCH }} && \ | ||
git commit -am "Updated notebooks via ${{ env.UPDATER_BRANCH }} GitHub action" --signoff && | ||
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$REPO_OWNER/$REPO_NAME.git | ||
git push origin ${{ env.UPDATER_BRANCH }} | ||
|
||
- name: Create Pull Request | ||
run: | | ||
gh pr create --repo $UPSTREAM_OWNER/$REPO_NAME \ | ||
--title "$pr_title" \ | ||
--body "$pr_body" \ | ||
--head $REPO_OWNER:$UPDATER_BRANCH \ | ||
--base $BRANCH_NAME | ||
env: | ||
pr_title: "[Digest Updater Action] Update notebook's pipfile to sync with Codeflare-SDK release" | ||
pr_body: | | ||
:rocket: This is an automated Pull Request. | ||
|
||
This PR updates the `Pipfile` to sync with latest Codeflare-SDK release. | ||
|
||
:exclamation: **IMPORTANT NOTE**: Remember to delete the ` ${{ env.UPDATER_BRANCH }}` branch after merging the changes |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.