Skip to content

Commit 0d5db3d

Browse files
authored
[RHOAIENG-12621] Update the updater github action to the latest branch (#716)
* Update of workbench images and runtime images digest updater GHAs This is for [1]. * [1] https://issues.redhat.com/browse/RHOAIENG-12621 * Small improvements for the runtime digest updater GHA. * Update GHA for digest updaters to be closer the content in downstream Just some formatting so that the code is similar to what is in downstream for easier comparability. * DONT COMMIT this one
1 parent bebc11e commit 0d5db3d

File tree

2 files changed

+143
-148
lines changed

2 files changed

+143
-148
lines changed

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

Lines changed: 119 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ on: # yamllint disable-line rule:truthy
1313
env:
1414
DIGEST_UPDATER_BRANCH: digest-updater-${{ github.run_id }}
1515
BRANCH_NAME: ${{ github.event.inputs.branch || 'main' }}
16-
RELEASE_VERSION_N: 2024a
17-
RELEASE_VERSION_N_1: 2023b
16+
RELEASE_VERSION_N: 2024b
17+
RELEASE_VERSION_N_1: 2024a
1818
jobs:
1919
initialize:
2020
runs-on: ubuntu-latest
@@ -36,9 +36,9 @@ jobs:
3636
# Create a new branch
3737
- name: Create a new branch
3838
run: |
39-
echo ${{ env.DIGEST_UPDATER_BRANCH }}
40-
git checkout -b ${{ env.DIGEST_UPDATER_BRANCH }}
41-
git push --set-upstream origin ${{ env.DIGEST_UPDATER_BRANCH }}
39+
echo ${{ env.DIGEST_UPDATER_BRANCH }}
40+
git checkout -b ${{ env.DIGEST_UPDATER_BRANCH }}
41+
git push --set-upstream origin ${{ env.DIGEST_UPDATER_BRANCH }}
4242
4343
update-n-version:
4444
needs: [initialize]
@@ -48,8 +48,8 @@ jobs:
4848
steps:
4949
- name: Configure Git
5050
run: |
51-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
52-
git config --global user.name "GitHub Actions"
51+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
52+
git config --global user.name "GitHub Actions"
5353
5454
# Get latest build commit from the https://github.com/opendatahub-io/notebooks/${release_branch} using this as identifier for the latest tag name
5555
- name: Retrive latest commit hash from the release branch
@@ -65,64 +65,65 @@ jobs:
6565
with:
6666
ref: ${{ env.DIGEST_UPDATER_BRANCH }}
6767

68-
- name: Update the param.env file
68+
- name: Update the params.env file
6969
run: |
70-
PARAMS_ENV_PATH="manifests/base/params.env"
71-
72-
echo Latest commit is: ${{ steps.hash-n.outputs.HASH_N }} on ${{ env.RELEASE_VERSION_N }}
73-
74-
# Get the complete list of images N-version to update
75-
IMAGES=$(cat "${PARAMS_ENV_PATH}" | grep "\-n=" | cut -d "=" -f 1)
76-
77-
for image in ${IMAGES}; do
78-
echo "CHECKING: '${image}'"
79-
img=$(grep -E "${image}=" "${PARAMS_ENV_PATH}" | cut -d '=' -f2)
80-
registry=$(echo "${img}" | cut -d '@' -f1)
81-
82-
skopeo_metadata=$(skopeo inspect --retry-times 3 "docker://${img}")
83-
84-
src_tag=$(echo "${skopeo_metadata}" | jq '.Env[] | select(startswith("OPENSHIFT_BUILD_NAME=")) | split("=")[1]' | tr -d '"' | sed 's/-amd64$//')
85-
regex="^$src_tag-${{ env.RELEASE_VERSION_N}}-\d+-${{ steps.hash-n.outputs.HASH_N }}\$"
86-
latest_tag=$(echo "${skopeo_metadata}" | jq -r --arg regex "$regex" '.RepoTags | map(select(. | test($regex))) | .[0]')
87-
# use `--no-tags` for skopeo once available in newer version
88-
digest=$(skopeo inspect --retry-times 3 "docker://${registry}:${latest_tag}" | jq .Digest | tr -d '"')
89-
output="${registry}@${digest}"
90-
echo "NEW: ${output}"
91-
sed -i "s|${image}=.*|${image}=${output}|" "${PARAMS_ENV_PATH}"
92-
done
93-
94-
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
95-
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
96-
git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
97-
git add "${PARAMS_ENV_PATH}" && \
98-
git commit -m "Update images for release N via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && \
99-
git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
100-
else
101-
echo "There were no changes detected in the images for the ${{ env.RELEASE_VERSION_N }}"
102-
fi
70+
PARAMS_ENV_PATH="manifests/base/params.env"
71+
72+
echo Latest commit is: ${{ steps.hash-n.outputs.HASH_N }} on ${{ env.RELEASE_VERSION_N }}
73+
74+
# Get the complete list of images N-version to update
75+
IMAGES=$(grep "\-n=" "${PARAMS_ENV_PATH}" | cut -d "=" -f 1)
76+
77+
for image in ${IMAGES}; do
78+
echo "CHECKING: '${image}'"
79+
img=$(grep -E "${image}=" "${PARAMS_ENV_PATH}" | cut -d '=' -f2)
80+
registry=$(echo "${img}" | cut -d '@' -f1)
81+
82+
skopeo_metadata=$(skopeo inspect --retry-times 3 "docker://${img}")
83+
84+
src_tag=$(echo "${skopeo_metadata}" | jq '.Env[] | select(startswith("OPENSHIFT_BUILD_NAME=")) | split("=")[1]' | tr -d '"' | sed 's/-amd64$//')
85+
src_tag2=$(echo $src_tag | sed 's/python-3.9/python-3.11/')
86+
regex="^$src_tag2-${{ env.RELEASE_VERSION_N}}-\d+-${{ steps.hash-n.outputs.HASH_N }}\$"
87+
latest_tag=$(echo "${skopeo_metadata}" | jq -r --arg regex "$regex" '.RepoTags | map(select(. | test($regex))) | .[0]')
88+
# use `--no-tags` for skopeo once available in newer version
89+
digest=$(skopeo inspect --retry-times 3 "docker://${registry}:${latest_tag}" | jq .Digest | tr -d '"')
90+
output="${registry}@${digest}"
91+
echo "NEW: ${output}"
92+
sed -i "s|${image}=.*|${image}=${output}|" "${PARAMS_ENV_PATH}"
93+
done
94+
95+
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
96+
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
97+
git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
98+
git add "${PARAMS_ENV_PATH}" && \
99+
git commit -m "Update images for release N via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && \
100+
git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
101+
else
102+
echo "There were no changes detected in the images for the ${{ env.RELEASE_VERSION_N }}"
103+
fi
103104
104105
- name: Update the commit.env file
105106
run: |
106-
COMMIT_ENV_PATH="manifests/base/commit.env"
107-
108-
echo Latest commit is: ${{ steps.hash-n.outputs.HASH_N }} on ${{ env.RELEASE_VERSION_N }}
109-
# Get the complete list of images N-1-version to update
110-
COMMIT=$(grep "\-n=" "${COMMIT_ENV_PATH}" | cut -d "=" -f 1)
111-
112-
for val in ${COMMIT}; do
113-
echo "${val}"
114-
sed -i "s|${val}=.*|${val}=${{ steps.hash-n.outputs.HASH_N }}|" "${COMMIT_ENV_PATH}"
115-
done
116-
117-
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
118-
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
119-
git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
120-
git add "${COMMIT_ENV_PATH}" && \
121-
git commit -m "Update image commits for release N via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && \
122-
git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
123-
else
124-
echo "There were no changes detected in the images for the ${{ env.RELEASE_VERSION_N }}"
125-
fi
107+
COMMIT_ENV_PATH="manifests/base/commit.env"
108+
109+
echo Latest commit is: ${{ steps.hash-n.outputs.HASH_N }} on ${{ env.RELEASE_VERSION_N }}
110+
# Get the complete list of commits N-version to update
111+
COMMIT=$(grep "\-n=" "${COMMIT_ENV_PATH}" | cut -d "=" -f 1)
112+
113+
for val in ${COMMIT}; do
114+
echo "${val}"
115+
sed -i "s|${val}=.*|${val}=${{ steps.hash-n.outputs.HASH_N }}|" "${COMMIT_ENV_PATH}"
116+
done
117+
118+
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
119+
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
120+
git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
121+
git add "${COMMIT_ENV_PATH}" && \
122+
git commit -m "Update image commits for release N via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && \
123+
git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
124+
else
125+
echo "There were no changes detected in the images for the ${{ env.RELEASE_VERSION_N }}"
126+
fi
126127
127128
update-n-1-version:
128129
needs: [initialize, update-n-version]
@@ -132,8 +133,8 @@ jobs:
132133
steps:
133134
- name: Configure Git
134135
run: |
135-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
136-
git config --global user.name "GitHub Actions"
136+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
137+
git config --global user.name "GitHub Actions"
137138
138139
# Get latest build commit from the https://github.com/opendatahub-io/notebooks/${release_branch} using this as identifier for the latest tag name
139140
- name: Retrive latest commit hash from the release branch
@@ -151,62 +152,62 @@ jobs:
151152

152153
- name: Update the param.env file
153154
run: |
154-
PARAMS_ENV_PATH="manifests/base/params.env"
155-
156-
echo Latest commit is: ${{ steps.hash-n-1.outputs.HASH_N_1 }} on ${{ env.RELEASE_VERSION_N_1 }}
157-
158-
# Get the complete list of images N-1-version to update
159-
IMAGES=$(cat "${PARAMS_ENV_PATH}" | grep "\-n-1=" | cut -d "=" -f 1)
160-
161-
for image in ${IMAGES}; do
162-
echo "CHECKING: '${image}'"
163-
img=$(grep -E "${image}=" "${PARAMS_ENV_PATH}" | cut -d '=' -f2)
164-
registry=$(echo "${img}" | cut -d '@' -f1)
165-
166-
skopeo_metadata=$(skopeo inspect --retry-times 3 "docker://${img}")
167-
168-
src_tag=$(echo "${skopeo_metadata}" | jq '.Env[] | select(startswith("OPENSHIFT_BUILD_NAME=")) | split("=")[1]' | tr -d '"' | sed 's/-amd64$//')
169-
regex="^$src_tag-${{ env.RELEASE_VERSION_N_1}}-\d+-${{ steps.hash-n-1.outputs.HASH_N_1 }}\$"
170-
latest_tag=$(echo "${skopeo_metadata}" | jq -r --arg regex "$regex" '.RepoTags | map(select(. | test($regex))) | .[0]')
171-
# use `--no-tags` for skopeo once available in newer version
172-
digest=$(skopeo inspect --retry-times 3 "docker://${registry}:${latest_tag}" | jq .Digest | tr -d '"')
173-
output="${registry}@${digest}"
174-
echo "NEW: ${output}"
175-
sed -i "s|${image}=.*|${image}=${output}|" "${PARAMS_ENV_PATH}"
176-
done
177-
178-
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
179-
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
180-
git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
181-
git add "${PARAMS_ENV_PATH}" && \
182-
git commit -m "Update images for release N-1 via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && \
183-
git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
184-
else
185-
echo "There were no changes detected in the images for the ${{ env.RELEASE_VERSION_N_1 }}"
186-
fi
155+
PARAMS_ENV_PATH="manifests/base/params.env"
156+
157+
echo Latest commit is: ${{ steps.hash-n-1.outputs.HASH_N_1 }} on ${{ env.RELEASE_VERSION_N_1 }}
158+
159+
# Get the complete list of images N-1-version to update
160+
IMAGES=$(grep "\-n-1=" "${PARAMS_ENV_PATH}" | cut -d "=" -f 1)
161+
162+
for image in ${IMAGES}; do
163+
echo "CHECKING: '${image}'"
164+
img=$(grep -E "${image}=" "${PARAMS_ENV_PATH}" | cut -d '=' -f2)
165+
registry=$(echo "${img}" | cut -d '@' -f1)
166+
167+
skopeo_metadata=$(skopeo inspect --retry-times 3 "docker://${img}")
168+
169+
src_tag=$(echo "${skopeo_metadata}" | jq '.Env[] | select(startswith("OPENSHIFT_BUILD_NAME=")) | split("=")[1]' | tr -d '"' | sed 's/-amd64$//')
170+
regex="^$src_tag-${{ env.RELEASE_VERSION_N_1}}-\d+-${{ steps.hash-n-1.outputs.HASH_N_1 }}\$"
171+
latest_tag=$(echo "${skopeo_metadata}" | jq -r --arg regex "$regex" '.RepoTags | map(select(. | test($regex))) | .[0]')
172+
# use `--no-tags` for skopeo once available in newer version
173+
digest=$(skopeo inspect --retry-times 3 "docker://${registry}:${latest_tag}" | jq .Digest | tr -d '"')
174+
output="${registry}@${digest}"
175+
echo "NEW: ${output}"
176+
sed -i "s|${image}=.*|${image}=${output}|" "${PARAMS_ENV_PATH}"
177+
done
178+
179+
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
180+
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
181+
git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
182+
git add "${PARAMS_ENV_PATH}" && \
183+
git commit -m "Update images for release N-1 via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && \
184+
git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
185+
else
186+
echo "There were no changes detected in the images for the ${{ env.RELEASE_VERSION_N_1 }}"
187+
fi
187188
188189
- name: Update the commit.env file
189190
run: |
190-
COMMIT_ENV_PATH="manifests/base/commit.env"
191-
192-
echo Latest commit is: ${{ steps.hash-n-1.outputs.HASH_N_1 }} on ${{ env.RELEASE_VERSION_N_1 }}
193-
# Get the complete list of images N-1-version to update
194-
COMMIT=$(grep "\-n-1=" "${COMMIT_ENV_PATH}" | cut -d "=" -f 1)
195-
196-
for val in ${COMMIT}; do
197-
echo "${val}"
198-
sed -i "s|${val}=.*|${val}=${{ steps.hash-n-1.outputs.HASH_N_1 }}|" "${COMMIT_ENV_PATH}"
199-
done
200-
201-
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
202-
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
203-
git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
204-
git add "${COMMIT_ENV_PATH}" && \
205-
git commit -m "Update image commits for release N via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && \
206-
git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
207-
else
208-
echo "There were no changes detected in the images for the ${{ env.RELEASE_VERSION_N }}"
209-
fi
191+
COMMIT_ENV_PATH="manifests/base/commit.env"
192+
193+
echo Latest commit is: ${{ steps.hash-n-1.outputs.HASH_N_1 }} on ${{ env.RELEASE_VERSION_N_1 }}
194+
# Get the complete list of images N-1-version to update
195+
COMMIT=$(grep "\-n-1=" "${COMMIT_ENV_PATH}" | cut -d "=" -f 1)
196+
197+
for val in ${COMMIT}; do
198+
echo "${val}"
199+
sed -i "s|${val}=.*|${val}=${{ steps.hash-n-1.outputs.HASH_N_1 }}|" "${COMMIT_ENV_PATH}"
200+
done
201+
202+
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
203+
git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
204+
git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && \
205+
git add "${COMMIT_ENV_PATH}" && \
206+
git commit -m "Update image commits for release N-1 via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && \
207+
git push origin ${{ env.DIGEST_UPDATER_BRANCH }}
208+
else
209+
echo "There were no changes detected in the images for the ${{ env.RELEASE_VERSION_N_1 }}"
210+
fi
210211
211212
open-pull-request:
212213
needs: [update-n-version, update-n-1-version]
@@ -221,7 +222,7 @@ jobs:
221222
uses: repo-sync/pull-request@v2
222223
with:
223224
source_branch: ${{ env.DIGEST_UPDATER_BRANCH }}
224-
destination_branch: ${{ env.BRANCH_NAME}}
225+
destination_branch: ${{ env.BRANCH_NAME }}
225226
github_token: ${{ secrets.GITHUB_TOKEN }}
226227
pr_label: "automated pr"
227228
pr_title: "[Digest Updater Action] Update Notebook Images"
@@ -233,4 +234,4 @@ jobs:
233234
- `manifests/base/params.env` file with the latest updated SHA digests of the notebooks (N & N-1).
234235
- `manifests/base/commit.env` file with the latest commit (N & N-1).
235236
236-
:exclamation: **IMPORTANT NOTE**: Remember to delete the ` ${{ env.DIGEST_UPDATER_BRANCH }}` branch after merging the changes
237+
:exclamation: **IMPORTANT NOTE**: Remember to delete the `${{ env.DIGEST_UPDATER_BRANCH }}` branch after merging the changes

0 commit comments

Comments
 (0)