mirror of
https://github.com/Icinga/docker-icinga2.git
synced 2026-05-05 02:46:12 +02:00
action.yml: checkout the source, build a Docker image and push it
This commit is contained in:
parent
7c36ba6643
commit
183233801f
1
Dockerfile
Normal file
1
Dockerfile
Normal file
@ -0,0 +1 @@
|
||||
FROM debian:buster-slim
|
||||
20
action.Dockerfile
Normal file
20
action.Dockerfile
Normal file
@ -0,0 +1,20 @@
|
||||
FROM buildpack-deps:scm as clone
|
||||
SHELL ["/bin/bash", "-exo", "pipefail", "-c"]
|
||||
|
||||
RUN mkdir actions ;\
|
||||
cd actions ;\
|
||||
git clone --bare https://github.com/actions/checkout.git ;\
|
||||
git -C checkout.git archive --prefix=checkout/ v2 |tar -x ;\
|
||||
git clone --bare https://github.com/actions/upload-artifact.git ;\
|
||||
git -C upload-artifact.git archive --prefix=upload-artifact/ v2 |tar -x ;\
|
||||
rm -rf *.git
|
||||
|
||||
|
||||
FROM docker
|
||||
|
||||
RUN ["apk", "add", "bash", "grep", "nodejs"]
|
||||
COPY --from=clone /actions /actions
|
||||
|
||||
COPY action.bash Dockerfile /
|
||||
|
||||
CMD ["/action.bash"]
|
||||
50
action.bash
Executable file
50
action.bash
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
set -exo pipefail
|
||||
|
||||
TARGET=icinga/icinga2
|
||||
|
||||
mkimg () {
|
||||
test -n "$TAG"
|
||||
|
||||
node /actions/checkout/dist/index.js |grep -vFe ::add-matcher::
|
||||
docker build -f /Dockerfile -t "${TARGET}:$TAG" .
|
||||
STATE_isPost=1 node /actions/checkout/dist/index.js
|
||||
|
||||
docker save "${TARGET}:$TAG" |gzip >docker-save.tgz
|
||||
INPUT_NAME=docker-image INPUT_PATH=docker-save.tgz node /actions/upload-artifact/dist/index.js
|
||||
rm docker-save.tgz
|
||||
}
|
||||
|
||||
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")"
|
||||
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
|
||||
4
action.yml
Normal file
4
action.yml
Normal file
@ -0,0 +1,4 @@
|
||||
name: Icinga 2 Docker image
|
||||
runs:
|
||||
using: docker
|
||||
image: action.Dockerfile
|
||||
Loading…
x
Reference in New Issue
Block a user