diff --git a/.rsync-filter b/.rsync-filter new file mode 100644 index 0000000..c294b39 --- /dev/null +++ b/.rsync-filter @@ -0,0 +1,7 @@ +- .git/ +- ci/ +- *.j2 +- .gitignore +- Makefile +- publish.sh +- render.py diff --git a/Makefile b/Makefile index f16d532..b5e6f44 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,15 @@ KICKSTARTS = \ fedora-rpi.ks \ fedora.ks -.PHONY: all clean +.PHONY: all clean publish all: $(KICKSTARTS) %.ks: %.ks.j2 python3 render.py $< > $@ +publish: + sh publish.sh + clean: rm -f $(KICKSTARTS) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile new file mode 100644 index 0000000..cefdad6 --- /dev/null +++ b/ci/Jenkinsfile @@ -0,0 +1,29 @@ +pipeline { + agent { + kubernetes { + yamlFile 'ci/podTemplate.yaml' + yamlMergeStrategy merge() + defaultContainer 'build' + } + } + + stages { + stage('Build') { + steps { + sh 'make' + } + } + + stage('Publish') { + environment { + PUBLISH_PATH = "/var/www/html/kickstart/${BRANCH_NAME}/" + } + steps { + sshagent(['jenkins-pxe']) { + sh 'make publish' + } + } + } + } + +} diff --git a/ci/podTemplate.yaml b/ci/podTemplate.yaml new file mode 100644 index 0000000..96c06ce --- /dev/null +++ b/ci/podTemplate.yaml @@ -0,0 +1,12 @@ +spec: + containers: + - name: build + image: git.pyrocufflink.net/containerimages/jenkins-common + volumeMounts: + - mountPath: /etc/ssh/ssh_known_hosts + name: ssh-known-hosts + subPath: ssh_known_hosts + volumes: + - name: ssh-known-hosts + configMap: + name: ssh-known-hosts diff --git a/publish.sh b/publish.sh new file mode 100644 index 0000000..62f592c --- /dev/null +++ b/publish.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +: "${PUBLISH_HOST:=$(getent hosts pxe.pyrocufflink.blue | cut -d' ' -f2 | head -n1)}" +: "${PUBLISH_PATH:=/var/www/html/kickstart/}" + +ssh "${PUBLISH_HOST}" mkdir -p "${PUBLISH_PATH}" +rsync ${PRETEND+-n} -aiFF --delete ./ "${PUBLISH_HOST}:${PUBLISH_PATH}"