|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright The Conforma Contributors |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | +# SPDX-License-Identifier: Apache-2.0 |
| 17 | + |
| 18 | +# |
| 19 | +# Renovate should do be generating a PR for this automatically, but there |
| 20 | +# are times want to do it immediately, in which case you can use this script. |
| 21 | +# |
| 22 | + |
| 23 | +set -o errexit |
| 24 | +set -o nounset |
| 25 | +set -o pipefail |
| 26 | + |
| 27 | +# Find latest digest |
| 28 | +UBI_MINIMAL=registry.access.redhat.com/ubi9/ubi-minimal:latest |
| 29 | +NEW_DIGEST=$(skopeo inspect --raw docker://$UBI_MINIMAL | sha256sum | awk '{print $1}') |
| 30 | +echo "Found $UBI_MINIMAL:latest@$NEW_DIGEST" |
| 31 | + |
| 32 | +# Update docker files |
| 33 | +DOCKER_FILES=(Dockerfile Dockerfile.dist) |
| 34 | +for d in "${DOCKER_FILES[@]}" ; do |
| 35 | + echo "Updating $d" |
| 36 | + sed -E "s!^FROM $UBI_MINIMAL@sha256:[0-9a-f]+\$!FROM $UBI_MINIMAL@sha256:$NEW_DIGEST!" -i $d |
| 37 | +done |
| 38 | + |
| 39 | +# Update rpms.lock.yaml maybe |
| 40 | +hack/update-rpm-lock.sh |
| 41 | + |
| 42 | +# Make a branch and a commit |
| 43 | +CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) |
| 44 | +PR_BRANCH="ubi-bump-$CURRENT_BRANCH-$(date +%y%m%d%H)" |
| 45 | +git checkout -b $PR_BRANCH |
| 46 | +git add ${DOCKER_FILES[@]} rpms.lock.yaml |
| 47 | +git commit -m "chore(deps): Update ubi-minimal base image" |
| 48 | + |
| 49 | +# Push the branch ready to make a PR |
| 50 | +git push origin $PR_BRANCH:$PR_BRANCH |
| 51 | +# Todo maybe: gh pr create ... |
| 52 | +echo "Be careful to choose the right target branch!" |
0 commit comments