Skip to content

Commit

Permalink
Upgrade the digest updater workflow to update both versions of the no…
Browse files Browse the repository at this point in the history
…tebooks

Update the params.env file with the new release
  • Loading branch information
atheo89 committed Oct 16, 2023
1 parent 451c9c9 commit 26a13ba
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 31 deletions.
94 changes: 74 additions & 20 deletions .github/workflows/notebooks-digest-updater-upstream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ on:
inputs:
branch:
required: true
description: "Provide the name of the branch you want to update ex main, vYYYYx etc"
release-n:
required: true
description: "Provide release N version of the notebooks ex 2023a"
schedule:
- cron: "0 0 * * 5" #Scheduled every Friday
description: "Provide the name of the branch you want to update ex main, vYYYYx etc: "
# Put the scheduler on comment until automate the full release procedure
# schedule:
# - cron: "0 0 * * 5" #Scheduled every Friday
env:
DIGEST_UPDATER_BRANCH: digest-updater-${{ github.run_id }}
BRANCH_NAME: ${{ github.event.inputs.branch || 'main' }}
RELEASE_VERSION: ${{ github.event.inputs.release-n || '2023a' }}
RELEASE_VERSION_N: 2023b
RELEASE_VERSION_N_1: 2023a
jobs:
initialize:
runs-on: ubuntu-latest
Expand All @@ -26,8 +25,8 @@ jobs:
sudo apt-get -y update
sudo apt-get -y install skopeo
# Checkout the release branch
- name: Checkout release branch
# Checkout the branch
- name: Checkout branch
uses: actions/checkout@v3
with:
ref: ${{ env.BRANCH_NAME }}
Expand All @@ -50,17 +49,18 @@ jobs:
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
# Get the latest weekly build commit hash: https://github.com/opendatahub-io/notebooks/commits/2023a
# Get the latest weekly build commit hash: https://github.com/opendatahub-io/notebooks/commits/2023b
- name: Checkout upstream notebooks repo
uses: actions/checkout@v3
with:
repository: opendatahub-io/notebooks.git
ref: ${{ env.RELEASE_VERSION }}
- name: Retrive latest weekly commit hash from the release branch
id: hash
ref: ${{ env.RELEASE_VERSION_N }}

- name: Retrieve latest weekly commit hash from the release branch
id: hash-n
shell: bash
run: |
echo "HASH=$(git rev-parse --short HEAD)" >> ${GITHUB_OUTPUT}
echo "HASH_N=$(git rev-parse --short HEAD)" >> ${GITHUB_OUTPUT}
# Checkout the release branch to apply the updates
- name: Checkout release branch
Expand All @@ -70,29 +70,82 @@ jobs:

- name: Fetch digest, and update the param.env file
run: |
echo Latest commit is: ${{ steps.hash-n.outputs.HASH_N }} on ${{ env.RELEASE_VERSION_N}}
IMAGES=("odh-minimal-notebook-image-n" "odh-minimal-gpu-notebook-image-n" "odh-pytorch-gpu-notebook-image-n" "odh-generic-data-science-notebook-image-n" "odh-tensorflow-gpu-notebook-image-n" "odh-trustyai-notebook-image-n")
for ((i=0;i<${#IMAGES[@]};++i)); do
image=${IMAGES[$i]}
echo $image
img=$(cat manifests/base/params.env | grep -E "${image}=" | cut -d '=' -f2)
registry=$(echo $img | cut -d '@' -f1)
src_tag=$(skopeo inspect docker://$img | jq '.Env[] | select(startswith("OPENSHIFT_BUILD_NAME=")) | split("=")[1]' | tr -d '"')
regex="$src_tag-${{ env.RELEASE_VERSION}}-\d+-${{ steps.hash.outputs.HASH }}"
src_tag=$(skopeo inspect docker://$img | jq '.Env[] | select(startswith("OPENSHIFT_BUILD_NAME=")) | split("=")[1]' | tr -d '"' | sed 's/-amd64$//')
regex="$src_tag-${{ env.RELEASE_VERSION_N}}-\d+-${{ steps.hash-n.outputs.HASH_N }}"
latest_tag=$(skopeo inspect docker://$img | jq -r --arg regex "$regex" '.RepoTags | map(select(. | test($regex))) | .[0]')
digest=$(skopeo inspect docker://$registry:$latest_tag | jq .Digest | tr -d '"')
output=$registry@$digest
echo $output
sed -i "s|${image}=.*|${image}=$output|" manifests/base/params.env
done
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && git add manifests/base/params.env && git commit -m "Update images for release N via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
update-n-1-version:
needs: [ initialize, update-n-version ]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
# Get the latest weekly build commit hash: https://github.com/opendatahub-io/notebooks/commits/2023a
- name: Checkout upstream notebooks repo
uses: actions/checkout@v3
with:
repository: opendatahub-io/notebooks.git
ref: ${{ env.RELEASE_VERSION_N_1 }}

- name: Retrieve latest weekly commit hash from the release branch
id: hash-n-1
shell: bash
run: |
echo "HASH_N_1=$(git rev-parse --short HEAD)" >> ${GITHUB_OUTPUT}
# Checkout the release branch to apply the updates
- name: Checkout release branch
uses: actions/checkout@v3
with:
ref: ${{ env.DIGEST_UPDATER_BRANCH }}

- name: Fetch digest, and update the param.env file
run: |
echo Latest commit is: ${{ steps.hash-n-1.outputs.HASH_N_1 }} on ${{ env.RELEASE_VERSION_N_1}}
IMAGES=("odh-minimal-notebook-image-n-1" "odh-minimal-gpu-notebook-image-n-1" "odh-pytorch-gpu-notebook-image-n-1" "odh-generic-data-science-notebook-image-n-1" "odh-tensorflow-gpu-notebook-image-n-1" "odh-trustyai-notebook-image-n-1")
for ((i=0;i<${#IMAGES[@]};++i)); do
image=${IMAGES[$i]}
echo $image
img=$(cat manifests/base/params.env | grep -E "${image}=" | cut -d '=' -f2)
registry=$(echo $img | cut -d '@' -f1)
src_tag=$(skopeo inspect docker://$img | jq '.Env[] | select(startswith("OPENSHIFT_BUILD_NAME=")) | split("=")[1]' | tr -d '"' | sed 's/-amd64$//')
regex="$src_tag-${{ env.RELEASE_VERSION_N_1}}-\d+-${{ steps.hash-n-1.outputs.HASH_N_1 }}"
latest_tag=$(skopeo inspect docker://$img | jq -r --arg regex "$regex" '.RepoTags | map(select(. | test($regex))) | .[0]')
digest=$(skopeo inspect docker://$registry:$latest_tag | jq .Digest | tr -d '"')
output=$registry@$digest
echo $output
sed -i "s|${image}=.*|${image}=$output|" manifests/base/params.env
done
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && git add manifests/base/params.env && git commit -m "Update file via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && git add manifests/base/params.env && git commit -m "Update images for release N-1 via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
# Creates the Pull Request
open-pull-request:
needs: [ update-n-version ]
needs: [ update-n-version, update-n-1-version ]
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: pull-request
uses: repo-sync/pull-request@v2
with:
Expand All @@ -102,8 +155,9 @@ jobs:
pr_label: "automated pr"
pr_title: "[Digest Updater Action] Update notebook's imageStreams image tag to digest format"
pr_body: |
:rocket: This is a automated PR
:rocket: This is an automated Pull Request.
_Created by `/.github/workflows/digest-updater.yaml`
This PR updates the `manifests/base/params.env` file with the latest updated SHA digests of the notebooks (N & N-1).
Created by `/.github/workflows/notebooks-digest-updater-upstream.yaml`
:exclamation: **IMPORTANT NOTE**: Remember to delete the ` ${{ env.DIGEST_UPDATER_BRANCH }}` branch after merging the changes
23 changes: 12 additions & 11 deletions manifests/base/params.env
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
odh-minimal-notebook-image-n=quay.io/opendatahub/workbench-images@sha256:697f067146f21102333e8607d0dfc03ddb2225214489869dec0bbfb383e0f737
odh-minimal-notebook-image-n-1=quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75
odh-minimal-gpu-notebook-image-n=quay.io/opendatahub/workbench-images@sha256:a42bdf57c3d61d7a81a63d923c5a6ff1bf5e5284bb0aa972862fc063933ae733
odh-minimal-gpu-notebook-image-n-1=quay.io/opendatahub/notebooks@sha256:c13cd3410e31184986d44d36ba663ca2f2225d14e5b086b09fe221219a94b6de
odh-pytorch-gpu-notebook-image-n=quay.io/opendatahub/workbench-images@sha256:fc11d04f90817c15969203bced343f65ba7e3b10cb16861706e788da368f61f0
odh-pytorch-gpu-notebook-image-n-1=quay.io/opendatahub/notebooks@sha256:94c5d01b19a0f30c0ca18153c50f18317f42c224e82321ef39c43116e7184731
odh-generic-data-science-notebook-image-n=quay.io/opendatahub/workbench-images@sha256:a24baff695680fa3055218643f775156f9d1c8c95a9ec68a24928642b8f0393d
odh-generic-data-science-notebook-image-n-1=quay.io/opendatahub/notebooks@sha256:5df71f5542d2e0161f0f4342aa9a390679d72dc6fae192fd8da1e5671b27e8d4
odh-tensorflow-gpu-notebook-image-n=quay.io/opendatahub/workbench-images@sha256:e1092904418c1366704feccfdadcaee808bc4c94d78abc515724b2cf25c242c5
odh-tensorflow-gpu-notebook-image-n-1=quay.io/opendatahub/notebooks@sha256:fc52e4fbc8c1c70dfa22dbfe6b0353f5165c507c125df4438fca6a3f31fe976e
odh-trustyai-notebook-image-n=quay.io/opendatahub/workbench-images@sha256:326af53ec96cd1a4897f0add69db5edb1e4e60428d83fa3ee60347424374b4d8
odh-minimal-notebook-image-n=quay.io/opendatahub/workbench-images@sha256:61c165b94739386e8070d957a0ed0548719bafa7a3b66bb4f53adfc4ac697729
odh-minimal-notebook-image-n-1=quay.io/opendatahub/workbench-images@sha256:697f067146f21102333e8607d0dfc03ddb2225214489869dec0bbfb383e0f737
odh-minimal-gpu-notebook-image-n=quay.io/opendatahub/workbench-images@sha256:89b2e157447d19b153dfe667e74f6f871dae7a0cd8cad69d525918dcc78e4093
odh-minimal-gpu-notebook-image-n-1=quay.io/opendatahub/workbench-images@sha256:a42bdf57c3d61d7a81a63d923c5a6ff1bf5e5284bb0aa972862fc063933ae733
odh-pytorch-gpu-notebook-image-n=quay.io/opendatahub/workbench-images@sha256:05791c355613831bae3ec18f1a9b5e8d4d8c8073ffd3e162af3c6ae5d233d8fe
odh-pytorch-gpu-notebook-image-n-1=quay.io/opendatahub/workbench-images@sha256:fc11d04f90817c15969203bced343f65ba7e3b10cb16861706e788da368f61f0
odh-generic-data-science-notebook-image-n=quay.io/opendatahub/workbench-images@sha256:24eea7c729f17d8ec11e340bca55e6c86d14e95530fc7656dbf9c8f84f6ef84c
odh-generic-data-science-notebook-image-n-1=quay.io/opendatahub/workbench-images@sha256:a24baff695680fa3055218643f775156f9d1c8c95a9ec68a24928642b8f0393d
odh-tensorflow-gpu-notebook-image-n=quay.io/opendatahub/workbench-images@sha256:4946093512883baaaa611682056225d3f9373b3c8e28327e83838a60a43f7f9c
odh-tensorflow-gpu-notebook-image-n-1=quay.io/opendatahub/workbench-images@sha256:e1092904418c1366704feccfdadcaee808bc4c94d78abc515724b2cf25c242c5
odh-trustyai-notebook-image-n=quay.io/opendatahub/workbench-images@sha256:1584f960ecc06f5ca5c19dc517fe6366b7ce2dd484207625ccf615b789fa9c7f
odh-trustyai-notebook-image-n-1=quay.io/opendatahub/workbench-images@sha256:326af53ec96cd1a4897f0add69db5edb1e4e60428d83fa3ee60347424374b4d8
odh-habana-notebook-image-n=quay.io/opendatahub/workbench-images@sha256:901001f289a248f9e1cf46021efd5c0601bdeadde1e89e79112083d30600d07a
odh-habana-notebook-image-n-1=quay.io/opendatahub/workbench-images@sha256:b0821ae2abe45387a371108ac08e7474b64255e5c4519de5da594b4617fd79fe

0 comments on commit 26a13ba

Please sign in to comment.