From 117f865ee86f31ac15860bf18e8960e6873b6523 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Thu, 24 Nov 2022 17:25:46 +0100 Subject: [PATCH] ci: automate deployment Signed-off-by: Matej Focko --- .gitlab-ci.yml | 34 ++++++++++++++++++++++++++++++++++ makefile | 8 ++++---- regenerate-dots.sh | 2 +- regenerate-zips.sh | 8 +++----- 4 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..07df70b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,34 @@ +image: node:current-alpine3.15 + +stages: + - test + - deploy + +test: + stage: test + script: + - yarn install + - URL=http://localhost BASE_URL=/ yarn build + except: + - main + tags: + - shared-fi + +deploy: + stage: deploy + script: + - mkdir -p ~/.ssh + - ln -s $SSH_CONFIG ~/.ssh/config + - ln -s $SSH_KEY ~/.ssh/id_ed25519 + - ln -s $SSH_KNOWN_HOSTS ~/.ssh/known_hosts + - chmod 600 ~/.ssh/config ~/.ssh/id_ed25519 ~/.ssh/known_hosts + - apk update && apk add make graphviz zip openssh rsync + - yarn install + - make regenerate-dots + - make regenerate-zips + - make deploy-aisa + - make deploy-poincare + only: + - main + tags: + - shared-fi diff --git a/makefile b/makefile index 3f5bd61..81251fc 100644 --- a/makefile +++ b/makefile @@ -2,19 +2,19 @@ dev: regenerate-dots regenerate-zips URL=http://localhost BASE_URL=/ yarn run start deploy-aisa: - URL=https://fi.muni.cz BASE_URL=~xfocko/kb/ yarn run build + URL="https://fi.muni.cz" BASE_URL="~xfocko/kb/" yarn run build rsync -avzrlpptv --delete build/ aisa:~/public_html/kb/ deploy-poincare: - URL=https://fi.mfocko.xyz BASE_URL=/ yarn run build + URL="https://fi.mfocko.xyz" BASE_URL="/" yarn run build rsync -avzrlpptv --delete build/ poincare:~/public_html/fi/ deploy: regenerate-dots regenerate-zips deploy-aisa deploy-poincare regenerate-dots: - bash regenerate-dots.sh + sh regenerate-dots.sh regenerate-zips: - bash regenerate-zips.sh + sh regenerate-zips.sh .PHONY: deploy-aisa deploy-poincare regenerate-dots regenerate-zips diff --git a/regenerate-dots.sh b/regenerate-dots.sh index a4e9c79..166ac7e 100644 --- a/regenerate-dots.sh +++ b/regenerate-dots.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh FONT="Iosevka,'Iosevka Term','Cascadia Code','JetBrains Mono','Fira Code',monospace" diff --git a/regenerate-zips.sh b/regenerate-zips.sh index 13ac00f..3d5eec5 100644 --- a/regenerate-zips.sh +++ b/regenerate-zips.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # remove preexisting ZIPs find ./static/files -name '*.zip' -exec rm {} \; @@ -6,13 +6,11 @@ find ./static/files -name '*.zip' -exec rm {} \; for relative_path in $(find ./static/files -name '.zipit' -print); do relative_path=$(dirname $relative_path) base=$(basename $relative_path) - pushd $relative_path/.. - - echo "PWD: $PWD" + cd $relative_path/.. all_files=$(find $base/** ! -name '.zipit' -print) zip -9 $base.zip $all_files mv $base.zip $base/$base.zip - popd + cd - done; \ No newline at end of file