Files
debian-vnc-xfce-g3/docker/hooks/post_push
2024-01-29 19:43:18 -06:00

89 lines
4.0 KiB
Bash
Executable File

#!/bin/bash
### 2022-09-11 Warning
### It seems like the README publishing is currently not always working.
### Some changes on the Docker Hub side seem to be the reason.
### However, you can always copy the content generated by the utility
### 'util-readme.sh' ('preview' command) to the Docker Hub manually.
echo -e "\n==> EXECUTING @$(date -u +'%Y-%m-%d_%H-%M-%S'): ${0} $@\n"
declare _mydir=$(dirname $0)
source "${_mydir}"/env.rc
source "${_mydir}"/util.rc
main() {
### There is a GitHub Gist containing the endpoints for the badges.
### Updating the GitHub Gist can be skipped by *not* setting the environment variable GIST_TOKEN.
### Warning! The value of the GIST_TOKEN is a real secret.
### The personal access token (PAT) should be created on the GitHub and it requires the 'gist' scope.
local created
local version_sticker
local version_sticker_verbose
local repo_building="${DOCKER_REPO##*/}"
local repo_deploy="${_deploy_repo##*/}"
local keeper_repo_tag="${_deploy_builder_tags[0]}"
### debugging support
# dump_environment
if [[ ! -f "${_build_context}/${_scrap_demand_stop_building}" ]] ; then
### essential environment variables must be already set
if [[ -n "${GIST_TOKEN}" && -n "${GIST_ID}" && -n "${DEPLOY_GIST_ID}" ]] ; then
if [[ ( -n "${repo_deploy}" && "${repo_deploy}" != "${_prohibited_repo_name}" ) \
|| ( "${FORCE_PUBLISHING_BUILDER_REPO:-0}" == "1" && -n "${repo_building}" && "${repo_building}" != "${_prohibited_repo_name}" ) ]] ; \
then
### get values for badges from the image metadata (labels)
created=$( get_label "${DOCKER_REPO}:${keeper_repo_tag}" "org.opencontainers.image.created" )
version_sticker=$( get_label "${DOCKER_REPO}:${keeper_repo_tag}" "any.accetto.version-sticker" )
version_sticker_verbose=$( cat "${_build_context}/${_scrap_version_sticker_verbose_current}" )
### update badge endpoints in the builder repository gist
for t in "${_deploy_builder_tags[@]}" ; do
update_gist "${GIST_ID}" "${_gist_key_created}" "${DOCKER_REPO}" "${t}" "${created}"
update_gist "${GIST_ID}" "${_gist_key_version_sticker}" "${DOCKER_REPO}" "${t}" "${version_sticker}"
update_gist "${GIST_ID}" "${_gist_key_version_sticker_verbose}" "${DOCKER_REPO}" "${t}" "${version_sticker_verbose}"
done
else
echo "Skipping builder gist update because of null or prohibited target repositories."
fi
### update badge endpoints for all tags in the deployment repository
if [[ -n "${repo_deploy}" && "${repo_deploy}" != "${_prohibited_repo_name}" ]] ; then
for t in "${_deploy_tags[@]}" ; do
### note that the builder and deployment repositories could be identical
### in that case skip the tag which has been already published above
if [[ "${DOCKER_REPO}" != "${_deploy_repo}" || "${keeper_repo_tag}" != "${t}" ]] ; then
update_gist "${DEPLOY_GIST_ID}" "${_gist_key_created}" "${_deploy_repo}" "${t}" "${created}"
update_gist "${DEPLOY_GIST_ID}" "${_gist_key_version_sticker}" "${_deploy_repo}" "${t}" "${version_sticker}"
update_gist "${DEPLOY_GIST_ID}" "${_gist_key_version_sticker_verbose}" "${_deploy_repo}" "${t}" "${version_sticker_verbose}"
fi
done
else
echo -e "\nSkipping update of deployment gist because of null or prohibited deployment repository.\n"
fi
else
echo "Skipping gist update. Required variables not set."
fi
fi
if [[ "${KEEP_HELPER_FILES}" != "1" ]] ; then
echo "Removing helper files"
cleanup_scrap_files
fi
}
main $@
echo -e "\n==> FINISHED @$(date -u +'%Y-%m-%d_%H-%M-%S'): ${0} $@\n"