1
0
Fork 0

ci: Begin Jenkins pipeline
dustin/chmod777/pipeline/head There was a failure building this commit Details

This is a very simple pipeline that consists of 3 steps:

1. Download the Hugo binary from Github (if necessary)
2. Run `hugo`
3. Publish the generated site with `rsync`
master
Dustin 2020-03-03 18:43:48 -06:00
parent 4ce9fb8c84
commit 47c6d1e61d
5 changed files with 77 additions and 0 deletions

4
.gitignore vendored
View File

@ -1,2 +1,6 @@
/hugo
/hugo-*
/hugo_*.tar.gz
/hugo_*_checksums.txt
/public/
/resources/_gen/

33
ci/Jenkinsfile vendored Normal file
View File

@ -0,0 +1,33 @@
pipeline {
agent any
options {
disableConcurrentBuilds()
}
triggers {
pollSCM ''
}
stages {
stage('Prepare') {
steps {
sh '. ci/prepare.sh'
}
}
stage('Build') {
steps {
sh '. ci/build.sh'
}
}
stage('Publish') {
steps {
sshagent(['jenkins-web']) {
sh '. ci/publish.sh'
}
}
}
}
}

5
ci/build.sh Normal file
View File

@ -0,0 +1,5 @@
# Remove unnecessary Cloudflare CSS
# https://github.com/rhazdon/hugo-theme-hello-friend-ng/issues/41
sed -i -e '/cloudflare/,+2d' themes/hello-friend-ng/layouts/partials/head.html
./hugo

30
ci/prepare.sh Normal file
View File

@ -0,0 +1,30 @@
HUGO_VERSION=0.66.0
case $(uname -m) in
i[23456]86)
HUGO_ARCH=32bit
;;
x86_64)
HUGO_ARCH=64bit
;;
aarch64)
HUGO_ARCH=ARM64
;;
armv7*)
HUGO_ARCH=ARM
;;
esac
HUGO_TAR=hugo_${HUGO_VERSION}_Linux-${HUGO_ARCH}.tar.gz
HUGO_BASE_URL=https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}
HUGO_TAR_URL=${HUGO_BASE_URL}/${HUGO_TAR}
HUGO_CHECKSUM_URL=${HUGO_BASE_URL}/hugo_${HUGO_VERSION}_checksums.txt
if [ ! -f hugo-${HUGO_VERSION} ]; then
rm -f ${HUGO_TAR} hugo_${HUGO_VERSION}_checksums.txt
curl -fJL -O "${HUGO_CHECKSUM_URL}" -O "${HUGO_TAR_URL}"
grep ${HUGO_TAR} hugo_${HUGO_VERSION}_checksums.txt | sha256sum -c
tar -xzOf ${HUGO_TAR} hugo > hugo-${HUGO_VERSION}
chmod +x hugo-${HUGO_VERSION}
fi
ln -sf hugo-${HUGO_VERSION} hugo

5
ci/publish.sh Normal file
View File

@ -0,0 +1,5 @@
: ${PUBLISH_USER:=webapp.chmod777}
: ${PUBLISH_HOST:=web0.pyrocufflink.blue}
: ${PUBLISH_PATH:=htdocs}
rsync -rti public/ ${PUBLISH_USER}@${PUBLISH_HOST}:${PUBLISH_PATH}