2023-03-10 23:51:29 +00:00
|
|
|
stages:
|
2023-03-17 01:01:20 +00:00
|
|
|
- build
|
2023-03-11 00:15:01 +00:00
|
|
|
- deploy
|
2023-03-10 23:51:29 +00:00
|
|
|
- notification
|
|
|
|
|
2023-03-17 01:01:20 +00:00
|
|
|
build-site:
|
|
|
|
image: node:lts
|
|
|
|
stage: build
|
|
|
|
cache:
|
|
|
|
paths:
|
|
|
|
- node_modules/
|
|
|
|
only:
|
|
|
|
- main
|
|
|
|
script:
|
|
|
|
- npm install
|
|
|
|
- npm run build
|
|
|
|
- rm -r public/assets/data/
|
|
|
|
- cp serve.json public
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- public
|
|
|
|
expire_in: 1 day
|
|
|
|
|
2023-03-06 18:12:59 +00:00
|
|
|
deploy-site:
|
2023-03-17 01:01:20 +00:00
|
|
|
image: node:lts
|
2023-03-06 18:12:59 +00:00
|
|
|
stage: deploy
|
2023-03-17 01:01:20 +00:00
|
|
|
only:
|
|
|
|
- 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:
|
2023-03-17 01:01:20 +00:00
|
|
|
- echo "Getting artifacts"
|
|
|
|
- ls public
|
|
|
|
- echo "Stopping screen session and cleaning"
|
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST -o StrictHostKeyChecking=no IdentitiesOnly=yes "screen -X -S website-firq-npx kill; rm -r -f public/*;"
|
|
|
|
- echo "Copying to proxmox machine"
|
|
|
|
- rsync -e "ssh -o StrictHostKeyChecking=no IdentitiesOnly=yes" -a --progress public/ $DEPLOY_USER@$DEPLOY_HOST:~/public
|
|
|
|
- echo "Restarting screen session"
|
|
|
|
- ssh $DEPLOY_USER@$DEPLOY_HOST -o StrictHostKeyChecking=no IdentitiesOnly=yes "screen -S website-firq-npx -dm npx serve public/ -p 9000 -c serve.json"
|
|
|
|
- echo "Website is up on https://firq.dev/"
|
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
|
2023-03-17 01:01:20 +00:00
|
|
|
- apk add rsync
|
2023-03-11 00:10:19 +00:00
|
|
|
- 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
|