inkletblot-com-v3/.gitlab-ci.yml
2022-12-04 15:40:51 +10:30

50 lines
1.6 KiB
YAML

stages:
- build
- deploy
# Don't have develop yet hehe
# develop-build-job:
# stage: build
# tags:
# - hugo
# script:
# - echo "Building configuration"
# - hugo
# only:
# - develop
main-build-job:
stage: build
image: jojomi/hugo
tags:
- hugo
script:
- echo "Building configuration"
- hugo
artifacts:
paths:
- public/
only:
- main
deploy-job:
stage: deploy
tags:
- hugo
environment:
name: Production
url: "$Live_Server_IP"
before_script:
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y)'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config'
script:
- tar zcf ../inkletblot-com.tar.gz ./public
- scp -o 'ProxyJump "$Live_Server_User"@"$Live_Server_IP"' -o StrictHostKeyChecking=no ../inkletblot-com.tar.gz "$Live_Server_User"@"$Live_Server_Target":/var/www/html
- ssh -J "$Live_Server_User"@"$Live_Server_IP" "$Live_Server_User"@"$Live_Server_Target" "rm -Rf /var/www/html/inkletblot-com_old && mv /var/www/html/inkletblot-com /var/www/html/inkletblot-com_old && mkdir /var/www/html/inkletblot-com_build && mkdir /var/www/html/inkletblot-com && tar zxf /var/www/html/inkletblot-com.tar.gz -C /var/www/html/inkletblot-com_build && mv /var/www/html/inkletblot-com_build/dist/inkletblot-com/* /var/www/html/inkletblot-com && rm -Rf /var/www/html/inkletblot-com_build && chmod -R 755 /var/www/html/inkletblot-com && exit"
only:
- main