Skip to content

Commit 161b3ed

Browse files
committed
Update digest updater workflow
1 parent 503090e commit 161b3ed

File tree

1 file changed

+83
-39
lines changed

1 file changed

+83
-39
lines changed

.github/workflows/notebooks-digest-updater-upstream.yaml

Lines changed: 83 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -51,53 +51,75 @@ jobs:
5151
git config --global user.email "github-actions[bot]@users.noreply.github.com"
5252
git config --global user.name "GitHub Actions"
5353
54-
# Get the latest weekly build commit hash: https://github.com/opendatahub-io/notebooks/commits/2024a
55-
- name: Checkout upstream notebooks repo
56-
uses: actions/checkout@v4
57-
with:
58-
repository: opendatahub-io/notebooks.git
59-
ref: ${{ env.RELEASE_VERSION_N }}
60-
61-
- name: Retrieve latest weekly commit hash from the release branch
54+
# Get latest build commit from the https://github.com/opendatahub-io/notebooks/${release_branch} using this as identifier for the latest tag name
55+
- name: Retrive latest commit hash from the release branch
6256
id: hash-n
6357
shell: bash
6458
run: |
65-
echo "HASH_N=$(git rev-parse --short HEAD)" >> ${GITHUB_OUTPUT}
59+
PAYLOAD=$(curl --silent -H 'Accept: application/vnd.github.v4.raw' https://api.github.com/repos/opendatahub-io/notebooks/commits?sha=$RELEASE_VERSION_N&per_page=1)
60+
echo "HASH_N=$(echo $PAYLOAD | jq -r '.[0].sha[0:7]')" >> ${GITHUB_OUTPUT}
6661
6762
# Checkout the release branch to apply the updates
6863
- name: Checkout release branch
6964
uses: actions/checkout@v4
7065
with:
7166
ref: ${{ env.DIGEST_UPDATER_BRANCH }}
7267

73-
- name: Fetch digest, and update the params.env file
68+
- name: Update the param.env file
7469
run: |
7570
echo Latest commit is: ${{ steps.hash-n.outputs.HASH_N }} on ${{ env.RELEASE_VERSION_N}}
76-
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")
71+
IMAGES=("odh-minimal-notebook-image-n"
72+
"odh-minimal-gpu-notebook-image-n"
73+
"odh-pytorch-gpu-notebook-image-n"
74+
"odh-generic-data-science-notebook-image-n"
75+
"odh-tensorflow-gpu-notebook-image-n"
76+
"odh-trustyai-notebook-image-n"
77+
"odh-codeserver-notebook-n"
78+
"odh-rstudio-notebook-n"
79+
"odh-rstudio-gpu-notebook-n")
80+
7781
for ((i=0;i<${#IMAGES[@]};++i)); do
7882
image=${IMAGES[$i]}
79-
echo $image
83+
echo "CHECKING: " $image
8084
img=$(cat manifests/base/params.env | grep -E "${image}=" | cut -d '=' -f2)
8185
registry=$(echo $img | cut -d '@' -f1)
8286
src_tag=$(skopeo inspect docker://$img | jq '.Env[] | select(startswith("OPENSHIFT_BUILD_NAME=")) | split("=")[1]' | tr -d '"' | sed 's/-amd64$//')
8387
regex="$src_tag-${{ env.RELEASE_VERSION_N}}-\d+-${{ steps.hash-n.outputs.HASH_N }}"
8488
latest_tag=$(skopeo inspect docker://$img | jq -r --arg regex "$regex" '.RepoTags | map(select(. | test($regex))) | .[0]')
8589
digest=$(skopeo inspect docker://$registry:$latest_tag | jq .Digest | tr -d '"')
8690
output=$registry@$digest
87-
echo $output
91+
echo "NEW:" $output
8892
sed -i "s|${image}=.*|${image}=$output|" manifests/base/params.env
8993
done
90-
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 }}
94+
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
95+
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 }}
96+
else
97+
echo "There were no changes detected in the images for the ${{ env.RELEASE_VERSION_N}}"
98+
fi
9199
92-
- name: Fetch digest, and update the commit.env file
100+
- name: Update the commit.env file
93101
run: |
94102
echo Latest commit is: ${{ steps.hash-n.outputs.HASH_N }} on ${{ env.RELEASE_VERSION_N}}
95-
COMMIT=("odh-minimal-notebook-image-commit-n" "odh-minimal-gpu-notebook-image-commit-n" "odh-pytorch-gpu-notebook-image-commit-n" "odh-generic-data-science-notebook-image-commit-n" "odh-tensorflow-gpu-notebook-image-commit-n" "odh-trustyai-notebook-image-commit-n")
103+
COMMIT=("odh-minimal-notebook-image-commit-n"
104+
"odh-minimal-gpu-notebook-image-commit-n"
105+
"odh-pytorch-gpu-notebook-image-commit-n"
106+
"odh-generic-data-science-notebook-image-commit-n"
107+
"odh-tensorflow-gpu-notebook-image-commit-n"
108+
"odh-trustyai-notebook-image-commit-n"
109+
"odh-codeserver-notebook-n"
110+
"odh-rstudio-notebook-n"
111+
"odh-rstudio-gpu-notebook-n")
112+
96113
for val in "${COMMIT[@]}"; do
97114
echo $val
98115
sed -i "s|${val}=.*|${val}=${{ steps.hash-n.outputs.HASH_N }}|" manifests/base/commit.env
99116
done
100-
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && git add manifests/base/commit.env && git commit -m "Update image commits for release N via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
117+
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
118+
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && git add manifests/base/commit.env && git commit -m "Update image commits for release N via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
119+
else
120+
echo "There were no changes detected in the images for the ${{ env.RELEASE_VERSION_N}}"
121+
fi
122+
101123
update-n-1-version:
102124
needs: [initialize, update-n-version]
103125
runs-on: ubuntu-latest
@@ -109,54 +131,74 @@ jobs:
109131
git config --global user.email "github-actions[bot]@users.noreply.github.com"
110132
git config --global user.name "GitHub Actions"
111133
112-
# Get the latest weekly build commit hash: https://github.com/opendatahub-io/notebooks/commits/2023b
113-
- name: Checkout upstream notebooks repo
114-
uses: actions/checkout@v4
115-
with:
116-
repository: opendatahub-io/notebooks.git
117-
ref: ${{ env.RELEASE_VERSION_N_1 }}
118-
119-
- name: Retrieve latest weekly commit hash from the release branch
134+
# Get latest build commit from the https://github.com/opendatahub-io/notebooks/${release_branch} using this as identifier for the latest tag name
135+
- name: Retrive latest commit hash from the release branch
120136
id: hash-n-1
121137
shell: bash
122138
run: |
123-
echo "HASH_N_1=$(git rev-parse --short HEAD)" >> ${GITHUB_OUTPUT}
139+
PAYLOAD=$(curl --silent -H 'Accept: application/vnd.github.v4.raw' https://api.github.com/repos/opendatahub-io/notebooks/commits?sha=$RELEASE_VERSION_N_1&per_page=1)
140+
echo "HASH_N_1=$(echo $PAYLOAD | jq -r '.[0].sha[0:7]')" >> ${GITHUB_OUTPUT}
124141
125142
# Checkout the release branch to apply the updates
126143
- name: Checkout release branch
127144
uses: actions/checkout@v4
128145
with:
129146
ref: ${{ env.DIGEST_UPDATER_BRANCH }}
130147

131-
- name: Fetch digest, and update the params.env file
148+
- name: Update the param.env file
132149
run: |
133150
echo Latest commit is: ${{ steps.hash-n-1.outputs.HASH_N_1 }} on ${{ env.RELEASE_VERSION_N_1}}
134-
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")
151+
IMAGES=("odh-minimal-notebook-image-n-1"
152+
"odh-minimal-gpu-notebook-image-n-1"
153+
"odh-pytorch-gpu-notebook-image-n-1"
154+
"odh-generic-data-science-notebook-image-n-1"
155+
"odh-tensorflow-gpu-notebook-image-n-1"
156+
"odh-trustyai-notebook-image-n-1"
157+
"odh-codeserver-notebook-n-1"
158+
"odh-rstudio-notebook-n-1"
159+
"odh-rstudio-gpu-notebook-n-1")
160+
135161
for ((i=0;i<${#IMAGES[@]};++i)); do
136162
image=${IMAGES[$i]}
137-
echo $image
163+
echo "CHECKING: " $image
138164
img=$(cat manifests/base/params.env | grep -E "${image}=" | cut -d '=' -f2)
139165
registry=$(echo $img | cut -d '@' -f1)
140166
src_tag=$(skopeo inspect docker://$img | jq '.Env[] | select(startswith("OPENSHIFT_BUILD_NAME=")) | split("=")[1]' | tr -d '"' | sed 's/-amd64$//')
141167
regex="$src_tag-${{ env.RELEASE_VERSION_N_1}}-\d+-${{ steps.hash-n-1.outputs.HASH_N_1 }}"
142168
latest_tag=$(skopeo inspect docker://$img | jq -r --arg regex "$regex" '.RepoTags | map(select(. | test($regex))) | .[0]')
143169
digest=$(skopeo inspect docker://$registry:$latest_tag | jq .Digest | tr -d '"')
144170
output=$registry@$digest
145-
echo $output
171+
echo "NEW:" $output
146172
sed -i "s|${image}=.*|${image}=$output|" manifests/base/params.env
147173
done
148-
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 }}
149-
150-
- name: Fetch digest, and update the commit.env file
174+
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
175+
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 }}
176+
else
177+
echo "There were no changes detected in the images for the ${{ env.RELEASE_VERSION_N_1}}"
178+
fi
179+
- name: Update the commit.env file
151180
run: |
152181
echo Latest commit is: ${{ steps.hash-n-1.outputs.HASH_N_1 }} on ${{ env.RELEASE_VERSION_N_1}}
153-
COMMIT=("odh-minimal-notebook-image-commit-n-1" "odh-minimal-gpu-notebook-image-commit-n-1" "odh-pytorch-gpu-notebook-image-commit-n-1" "odh-generic-data-science-notebook-image-commit-n-1" "odh-tensorflow-gpu-notebook-image-commit-n-1" "odh-trustyai-notebook-image-commit-n-1")
182+
COMMIT=("odh-minimal-notebook-image-commit-n-1"
183+
"odh-minimal-gpu-notebook-image-commit-n-1"
184+
"odh-pytorch-gpu-notebook-image-commit-n-1"
185+
"odh-generic-data-science-notebook-image-commit-n-1"
186+
"odh-tensorflow-gpu-notebook-image-commit-n-1"
187+
"odh-trustyai-notebook-image-commit-n-1"
188+
"odh-codeserver-notebook-n-1"
189+
"odh-rstudio-notebook-n-1"
190+
"odh-rstudio-gpu-notebook-n-1")
191+
154192
for val in "${COMMIT[@]}"; do
155193
echo $val
156194
sed -i "s|${val}=.*|${val}=${{ steps.hash-n-1.outputs.HASH_N_1 }}|" manifests/base/commit.env
157195
done
158-
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && git add manifests/base/commit.env && git commit -m "Update image commits for release N-1 via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
159-
# Creates the Pull Request
196+
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
197+
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && git add manifests/base/commit.env && git commit -m "Update image commits for release N via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
198+
else
199+
echo "There were no changes detected in the images for the ${{ env.RELEASE_VERSION_N}}"
200+
fi
201+
160202
open-pull-request:
161203
needs: [update-n-version, update-n-1-version]
162204
runs-on: ubuntu-latest
@@ -173,11 +215,13 @@ jobs:
173215
destination_branch: ${{ env.BRANCH_NAME}}
174216
github_token: ${{ secrets.GITHUB_TOKEN }}
175217
pr_label: "automated pr"
176-
pr_title: "[Digest Updater Action] Update notebook's imageStreams image tag to digest format"
218+
pr_title: "[Digest Updater Action] Update Notebook Images"
177219
pr_body: |
178220
:rocket: This is an automated Pull Request.
179-
180-
This PR updates the `manifests/base/params.env` file with the latest updated SHA digests of the notebooks (N & N-1).
181221
Created by `/.github/workflows/notebooks-digest-updater-upstream.yaml`
182222
223+
This PR updates the following files:
224+
- `manifests/base/params.env` file with the latest updated SHA digests of the notebooks (N & N-1).
225+
- `manifests/base/commit.env` file with the latest commit (N & N-1).
226+
183227
:exclamation: **IMPORTANT NOTE**: Remember to delete the ` ${{ env.DIGEST_UPDATER_BRANCH }}` branch after merging the changes

0 commit comments

Comments
 (0)