2024-03-02 05:09:37 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
function log() {
|
|
|
|
echo "[$(date +%H:%M:%S)] $@" >&2
|
|
|
|
}
|
|
|
|
|
2024-09-22 05:42:02 -04:00
|
|
|
[[ -n ${GITHUB_REF_NAME:-} ]] || {
|
2024-03-02 05:09:37 -05:00
|
|
|
log "ERR: This script is intended to run on a Github Action only."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
repo="ghcr.io/${GITHUB_REPOSITORY,,}"
|
|
|
|
tags=()
|
|
|
|
|
|
|
|
case "${GITHUB_REF_TYPE}" in
|
|
|
|
branch)
|
|
|
|
# Generic build to develop: Workflow has to limit branches to master
|
2024-09-22 05:42:02 -04:00
|
|
|
tags+=("${repo}:develop")
|
2024-03-02 05:09:37 -05:00
|
|
|
;;
|
|
|
|
tag)
|
|
|
|
# Build to latest & tag: Older tags are not intended to rebuild
|
2024-09-22 05:42:02 -04:00
|
|
|
tags+=("${repo}:latest" "${repo}:${GITHUB_REF_NAME}")
|
2024-03-02 05:09:37 -05:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
log "ERR: The ref type ${GITHUB_REF_TYPE} is not handled."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2024-09-22 05:42:02 -04:00
|
|
|
export IFS=,
|
|
|
|
echo "docker_build_tags=${tags[*]}" >>${GITHUB_OUTPUT}
|