mirror of
https://github.com/Icinga/docker-icinga2.git
synced 2025-11-09 19:31:35 +01:00
Rationale: for security reasons include the latest deps, at least in release images. Therefore include them everywhere, so the CI warns early enough.
64 lines
1.2 KiB
Bash
Executable File
64 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# Icinga 2 Docker image | (c) 2020 Icinga GmbH | GPLv2+
|
|
set -exo pipefail
|
|
|
|
TARGET=icinga/icinga2
|
|
|
|
cache () {
|
|
INPUT_KEY=docker-image/ccache INPUT_PATH=ccache \
|
|
STATE_CACHE_KEY=1 STATE_CACHE_RESULT=2 \
|
|
node "/actions/cache/dist/${1}/index.js"
|
|
}
|
|
|
|
mkimg () {
|
|
test -n "$TAG"
|
|
|
|
node /actions/checkout/dist/index.js |grep -vFe ::add-matcher::
|
|
cache restore
|
|
|
|
mkdir -p ccache
|
|
ln -vs "$(pwd)/ccache" ~/.ccache
|
|
|
|
/compile.bash
|
|
cache save
|
|
|
|
cp -r /entrypoint .
|
|
docker build -f /Dockerfile -t "${TARGET}:$TAG" .
|
|
|
|
STATE_isPost=1 node /actions/checkout/dist/index.js
|
|
}
|
|
|
|
push () {
|
|
test -n "$TAG"
|
|
|
|
if [ "$(tr -d '\n' <<<"$DOCKER_HUB_PASSWORD" |wc -c)" -gt 0 ]; then
|
|
docker login -u icingaadmin --password-stdin <<<"$DOCKER_HUB_PASSWORD"
|
|
docker push "${TARGET}:$TAG"
|
|
docker logout
|
|
fi
|
|
}
|
|
|
|
case "$GITHUB_EVENT_NAME" in
|
|
pull_request)
|
|
grep -qEe '^refs/pull/[0-9]+' <<<"$GITHUB_REF"
|
|
TAG="pr$(grep -oEe '[0-9]+' <<<"$GITHUB_REF")"
|
|
mkimg
|
|
;;
|
|
push)
|
|
grep -qEe '^refs/heads/.' <<<"$GITHUB_REF"
|
|
TAG="$(cut -d / -f 3- <<<"$GITHUB_REF" |tr / -)"
|
|
mkimg
|
|
push
|
|
;;
|
|
release)
|
|
grep -qEe '^refs/tags/v[0-9]' <<<"$GITHUB_REF"
|
|
TAG="$(cut -d v -f 2- <<<"$GITHUB_REF")"
|
|
mkimg
|
|
push
|
|
;;
|
|
*)
|
|
echo "Unknown event: $GITHUB_EVENT_NAME" >&2
|
|
false
|
|
;;
|
|
esac
|