diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..6cced24 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,39 @@ +stages: + - build + - deploy + +image: debian:latest +variables: + BUILDDIR: "build/" + +build: + stage: build + before_script: + - apt-get update + - apt-get install -y make lektor imagemagick + script: + - make build + artifacts: + expire_in: 12 hours + paths: + - "build/" + +deploy: + stage: deploy + only: + - master + environment: + name: production + url: https://ungleich.ch/ + before_script: + # Install dependencies + - apt-get update + - apt-get install -y make openssh-client rsync + # Configure the SSH Agent + - eval $(ssh-agent -s) + - echo "$CD_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null + - mkdir -p ~/.ssh + - echo "$CD_SSH_SERVER_HOSTKEYS" > ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + script: + - make deploy diff --git a/Makefile b/Makefile index b9fd51b..ff565d8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -BUILDDIR=../ungleich-staticcms-build +BUILDDIR?=../ungleich-staticcms-build DESTINATION=ungleichstatic@staticweb.ungleich.ch:/home/services/www/ungleichstatic/staticcms.ungleich.ch/www/u/ all: publish @@ -6,9 +6,10 @@ all: publish pull: git pull -publish: pull build permissions +publish: permissions rsync -av --delete --exclude .lektor/ $(BUILDDIR)/u/ $(DESTINATION) rsync -av --delete $(BUILDDIR)/sitemap.xml $(DESTINATION) + permissions: build find $(BUILDDIR) -type f -exec chmod 0644 {} \; find $(BUILDDIR) -type d -exec chmod 0755 {} \;