From 690c7e2a906c93127045fabbcffd247c69015e4f Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 25 Oct 2023 02:07:53 +0200 Subject: [PATCH] CI: Add GitLab CI to build and deploy - Build every branch, but only deploy the main branch - Deploy the main branch to next.hamburg.ccc.de --- .gitlab-ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..211852f --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,34 @@ +stages: + - build + - deploy + +build-website: + stage: build + image: alpine + before_script: + - apk update + - apk add tzdata hugo coreutils curl jq + script: + - ./fetch-calendar.sh + - sed -i "s#baseURL = 'https://hamburg.ccc.de/'#baseURL = 'https://next.hamburg.ccc.de/'#" hugo.toml + - hugo + artifacts: + expose_as: "website build" + name: "website-build-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA" + paths: + - public/ + expire_in: 1 month + +deploy-website: + stage: deploy + image: alpine + before_script: + - apk update + - apk add rsync openssh + script: + - chmod 400 $NEXT_SSH_DEPLOY_KEY + - rsync -r --delete -e "ssh -i $NEXT_SSH_DEPLOY_KEY -o 'UserKnownHostsFile $SSH_KNOWN_HOSTS_FILE'" public/ ccchh-website-deploy@public-web-static-intern.hamburg.ccc.de:/var/www/next.hamburg.ccc.de/ + rules: + - if: $CI_COMMIT_BRANCH == "main" + when: on_success + - when: never