firq-dev-website/.gitlab-ci.yml

46 lines
1.5 KiB
YAML

stages:
- deploy
- notification
deploy-site:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == "main"
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- echo "Connecting to proxmox machine"
- ssh $DEPLOY_USER@$DEPLOY_HOST -o StrictHostKeyChecking=no IdentitiesOnly=yes "screen -X -S website-firq-npx kill; rm -r -f public/*; cd build; git reset --hard; git pull; rm -r -f node_modules; npm install; npm run build; rm -r public/assets/data/; cp -R public ~; cp serve.json ~/public; cd ~; screen -S website-firq-npx -dm npx serve public/ -p 9000 -c serve.json"
success_notification:
stage: notification
before_script:
- apk update
- apk add curl
- apk add git
- apk add bash
script:
- wget https://raw.githubusercontent.com/DiscordHooks/gitlab-ci-discord-webhook/master/send.sh
- chmod +x send.sh
- ./send.sh success $WEBHOOK_URL
when: on_success
failure_notification:
stage: notification
before_script:
- apk update
- apk add curl
- apk add git
- apk add bash
script:
- wget https://raw.githubusercontent.com/DiscordHooks/gitlab-ci-discord-webhook/master/send.sh
- chmod +x send.sh
- ./send.sh failure $WEBHOOK_URL
when: on_failure