Skip to content

Commit

Permalink
Small improvements for the runtime digest updater GHA.
Browse files Browse the repository at this point in the history
  • Loading branch information
jstourac committed Sep 26, 2024
1 parent 16919c9 commit de5b621
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions .github/workflows/runtimes-digest-updater-upstream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,12 @@ jobs:

- name: Update Runtimes
run: |
echo Latest commit is: ${{ steps.hash-n.outputs.HASH_N }} on ${{ env.RELEASE_VERSION_N}}
PATHS=("jupyter/datascience/ubi9-python-3.9/runtime-images/datascience-ubi9-py39.json"
"jupyter/datascience/ubi9-python-3.9/runtime-images/pytorch-ubi9-py39.json"
"jupyter/datascience/ubi9-python-3.9/runtime-images/tensorflow-ubi9-py39.json"
"jupyter/datascience/ubi9-python-3.9/runtime-images/ubi9-py39.json"
"jupyter/datascience/ubi9-python-3.9/runtime-images/rocm-tensorflow-ubi9-py39.json"
"jupyter/datascience/ubi9-python-3.9/runtime-images/rocm-pytorch-ubi9-py39.json")
echo "Latest commit is: ${{ steps.hash-n.outputs.HASH_N }} on ${{ env.RELEASE_VERSION_N}}"
for ((i=0;i<${#PATHS[@]};++i)); do
path=${PATHS[$i]}
find . -name runtime-images -type d -exec find {} -type f -print \; | while read -r path; do
echo "Processing the '${path}' file."
if [[ ! -f "$path" ]]; then
echo "File $path does not exist. Skipping..."
continue
fi
img=$(cat ${path} | jq -r '.metadata.image_name')
img=$(jq -r '.metadata.image_name' "${path}")
name=$(echo "$path" | sed 's#.*runtime-images/\(.*\)-py.*#\1#')
py_version=$(echo "$path" | grep -o 'python-[0-9]\.[0-9]')
# Handling specific cases
Expand All @@ -91,21 +80,26 @@ jobs:
elif [[ $name == ubi* ]]; then
name="minimal-$name"
fi
registry=$(echo $img | cut -d '@' -f1)
registry=$(echo "$img" | cut -d '@' -f1)
regex="^runtime-$name-$py_version-${{ 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]')
echo "CHECKING: " $latest_tag
latest_tag=$(skopeo inspect "docker://$img" | jq -r --arg regex "$regex" '.RepoTags | map(select(. | test($regex))) | .[0]')
echo "CHECKING: ${latest_tag}"
if [[ -z "$latest_tag" ]]; then
echo "No matching tag found"
exit 1
fi
digest=$(skopeo inspect docker://$registry:$latest_tag | jq .Digest | tr -d '"')
output=$registry@$digest
echo "NEW: " $output
digest=$(skopeo inspect "docker://$registry:$latest_tag" | jq .Digest | tr -d '"')
output="${registry}@${digest}"
echo "NEW: ${output}"
jq --arg output "$output" '.metadata.image_name = $output' "$path" > "$path.tmp" && mv "$path.tmp" "$path"
done
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && git add jupyter/datascience/* && 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 jupyter/datascience/* && \
git commit -m "Update file via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && \
git push origin "${{ env.DIGEST_UPDATER_BRANCH }}"
else
echo "There were no changes detected in the images for the ${{ env.RELEASE_VERSION_N}}"
fi
Expand Down

0 comments on commit de5b621

Please sign in to comment.