Cache chrome for correct debian version

This commit is contained in:
Andrejs Cunskis 2022-11-08 12:49:31 +00:00 committed by Balasankar 'Balu' C
parent 03d90d36f2
commit 7d00e776ae
7 changed files with 40 additions and 13 deletions

View file

@ -15,7 +15,7 @@ function save-package() {
local REGISTRY_PACKAGE=${4:-$PKG}
local SOURCE_DEB=${5:-$DEB}
local URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${REGISTRY_PACKAGE}/${LATEST_VERSION}/${DEB}"
local URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${BUILD_OS}-${OS_VERSION}-${REGISTRY_PACKAGE}/${LATEST_VERSION}/${DEB}"
echo "Checking if ${PKG} v${LATEST_VERSION} is already cached"
local FILE_CHECK=$(curl --silent --location --head --output /dev/null --write "%{http_code}\\n" "$URL")
@ -81,6 +81,7 @@ function cache-chromium() {
function notify-chrome-updated() {
[ ! -f chrome-version ] && exit
[ -z "$CI_SLACK_WEBHOOK_URL" ] && exit
local chrome_version=$(cat chrome-version)
local msg="New version of chrome has been released: \`${chrome_version}\`!\n"
@ -103,5 +104,5 @@ if [ "$TARGETARCH" == "amd64" ]; then
cache-chromium
else
cache-chromium
notify-chrome-updated
[ "$NOTIFY_VERSION_UPDATE" == "true" ] && notify-chrome-updated || exit 0
fi

View file

@ -48,18 +48,26 @@ function build_debian() {
rm -rf /etc/apt/sources.list.d/google*.list
}
function build_ubi() {
echo "This OS is not supported for chrome install!"
exit 1
}
BUILD_OS=${BUILD_OS:-debian}
OS_VERSION=${OS_VERSION:-bullseye}
CHROME_VERSION=${1:-107.0.5304.87-1}
ARCH=${TARGETARCH:-amd64}
if [ "${ARCH}" == "amd64" ]; then
PKG=google-chrome-stable
else
PKG=chromium
fi
DOWNLOAD_URL_BASE="https://gitlab.com/api/v4/projects/1075790/packages/generic/${PKG}"
PKG=$([ "${ARCH}" == "amd64" ] && echo "google-chrome-stable" || echo "chromium")
DOWNLOAD_URL_BASE="https://gitlab.com/api/v4/projects/1075790/packages/generic/${BUILD_OS}-${OS_VERSION}-${PKG}"
if [[ $BUILD_OS =~ debian ]]; then
build_debian "$@"
elif [[ $BUILD_OS =~ ubi ]]; then
build_ubi "$@"
fi
if [ "${ARCH}" == "amd64" ]; then
google-chrome --version
else
chromium --version
fi

View file

@ -18,11 +18,13 @@ function print_image_args() {
debian:*)
CUSTOM_BASE_IMAGE="$1:$2"
BUILD_OS=debian
OS_VERSION=$2
;;
ubi:8.*)
CUSTOM_BASE_IMAGE="registry.access.redhat.com/ubi8/ubi:$2"
BUILD_OS=ubi
OS_VERSION=$2
;;
*) fail "Unknown image version $1:$2" ;;
@ -30,6 +32,7 @@ function print_image_args() {
printf -- "--build-arg CUSTOM_BASE_IMAGE=%s " "$CUSTOM_BASE_IMAGE"
printf -- "--build-arg BUILD_OS=%s " "$BUILD_OS"
printf -- "--build-arg OS_VERSION=%s " "$OS_VERSION"
}
function print_golang_args() {