Update Notebook Controllers' Image Tags #1
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
--- | |
# This is a gha updates automaticaly the notebook controller images. Can be run on demand before a new release | |
name: Update Notebook Controller Images With Latest Commit ID | |
on: # yamllint disable-line rule:truthy | |
workflow_dispatch: | |
inputs: | |
branch-name: | |
description: "Provide name of the branch, ex: v1.7-branch" | |
required: true | |
default: "v1.7-branch" | |
organization: | |
required: true | |
description: "Owner of origin notebooks repository used to open a PR" | |
default: "opendatahub-io" | |
env: | |
REPO_OWNER: ${{ github.event.inputs.organization }} | |
REPO_NAME: kubeflow | |
TEMP_UPDATER_BRANCH: temp-${{ github.run_id }} | |
BRANCH_NAME: ${{ github.event.inputs.branch-name }} | |
jobs: | |
update-notebook-controller-images: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout branch | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.BRANCH_NAME }} | |
- name: Checkout new branch | |
run: | | |
echo ${{ env.TEMP_UPDATER_BRANCH }} | |
git checkout -b ${{ env.TEMP_UPDATER_BRANCH }} | |
git push --set-upstream origin ${{ env.TEMP_UPDATER_BRANCH }} | |
- name: Configure Git | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "GitHub Actions" | |
- name: Retrive latest commit | |
id: commit-id | |
shell: bash | |
run: | | |
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) | |
echo "COMMIT_ID=$(echo $PAYLOAD | jq -r '.[0].sha[0:7]')" >> ${GITHUB_OUTPUT} | |
- name: Update related files | |
id: apply-changes | |
run: | | |
COMMIT_ID=${{ steps.commit-id.outputs.COMMIT_ID }} | |
echo "Updating files with COMMIT_ID=${COMMIT_ID}" | |
sed -i "s/\(odh-kf-notebook-controller-image=quay\.io\/opendatahub\/kubeflow-notebook-controller:1\.7-\)[a-z0-9]\{7\}/\1${COMMIT_ID}/" components/notebook-controller/config/overlays/openshift/params.env | |
sed -i "s/\(odh-notebook-controller-image=quay\.io\/opendatahub\/odh-notebook-controller:1\.7-\)[a-z0-9]\{7\}/\1${COMMIT_ID}/" components/odh-notebook-controller/config/base/params.env | |
sed -i "s/\(KF_TAG ?= 1\.7-\)[a-z0-9]\{7\}/\1${COMMIT_ID}/" components/odh-notebook-controller/Makefile | |
git status | |
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then | |
echo "Changes detected, committing and pushing..." | |
git fetch origin ${{ env.TEMP_UPDATER_BRANCH }} | |
git pull origin ${{ env.TEMP_UPDATER_BRANCH }} | |
git add components/notebook-controller/config/overlays/openshift/params.env | |
git add components/odh-notebook-controller/config/base/params.env | |
git add components/odh-notebook-controller/Makefile | |
git commit -m "Update odh and notebook-controller with image 1.7-${COMMIT_ID}" | |
git push origin ${{ env.TEMP_UPDATER_BRANCH }} | |
git log --oneline | |
else | |
echo "There were no changes detected on ${{ env.BRANCH_NAME }}" | |
fi | |
- name: Create Pull Request | |
run: | | |
gh pr create --repo https://github.com/$REPO_OWNER/$REPO_NAME.git \ | |
--title "$pr_title" \ | |
--body "$pr_body" \ | |
--head $REPO_OWNER:${{ env.TEMP_UPDATER_BRANCH }} \ | |
--base ${{ env.BRANCH_NAME }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
pr_title: "[GHA] Update odh and notebook-controller with image 1.7-${{ steps.commit-id.outputs.COMMIT_ID }}" | |
pr_body: | | |
:robot: This is an automated Pull Request created by `/.github/workflows/notebook-controller-images-updater.yaml`. | |
Have been updated the following related files: | |
- components/notebook-controller/config/overlays/openshift/params.env | |
- components/odh-notebook-controller/config/base/params.env | |
- components/odh-notebook-controller/Makefile |