2023-03-10 23:51:29 +00:00
|
|
|
stages:
|
2023-03-11 00:15:01 +00:00
|
|
|
- deploy
|
2023-03-10 23:51:29 +00:00
|
|
|
- notification
|
|
|
|
|
2023-03-06 18:12:59 +00:00
|
|
|
deploy-site:
|
|
|
|
stage: deploy
|
2023-03-07 19:38:49 +00:00
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_BRANCH == "main"
|
2023-03-06 18:12:59 +00:00
|
|
|
before_script:
|
2023-03-10 23:51:29 +00:00
|
|
|
- '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"
|
2023-03-16 17:12:46 +00:00
|
|
|
- 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; cp -R public ~; cp serve.json ~/public; cd ~; screen -S website-firq-npx -dm npx serve public/ -p 9000 -c serve.json"
|
2023-03-06 18:12:59 +00:00
|
|
|
|
2023-03-10 23:51:29 +00:00
|
|
|
success_notification:
|
|
|
|
stage: notification
|
2023-03-11 00:04:56 +00:00
|
|
|
before_script:
|
2023-03-11 00:10:19 +00:00
|
|
|
- apk update
|
|
|
|
- apk add curl
|
|
|
|
- apk add git
|
2023-03-11 00:31:48 +00:00
|
|
|
- apk add bash
|
2023-03-10 23:51:29 +00:00
|
|
|
script:
|
2023-03-11 00:31:48 +00:00
|
|
|
- wget https://raw.githubusercontent.com/DiscordHooks/gitlab-ci-discord-webhook/master/send.sh
|
2023-03-10 23:51:29 +00:00
|
|
|
- chmod +x send.sh
|
|
|
|
- ./send.sh success $WEBHOOK_URL
|
|
|
|
when: on_success
|
|
|
|
failure_notification:
|
|
|
|
stage: notification
|
2023-03-11 00:04:56 +00:00
|
|
|
before_script:
|
2023-03-11 00:10:19 +00:00
|
|
|
- apk update
|
|
|
|
- apk add curl
|
|
|
|
- apk add git
|
2023-03-11 00:31:48 +00:00
|
|
|
- apk add bash
|
2023-01-21 18:23:34 +00:00
|
|
|
script:
|
2023-03-11 00:31:48 +00:00
|
|
|
- wget https://raw.githubusercontent.com/DiscordHooks/gitlab-ci-discord-webhook/master/send.sh
|
2023-03-10 23:51:29 +00:00
|
|
|
- chmod +x send.sh
|
|
|
|
- ./send.sh failure $WEBHOOK_URL
|
|
|
|
when: on_failure
|