generated from kiwilan/fastify-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
35 lines (32 loc) · 1.02 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# A pipeline is composed of independent jobs that run scripts, grouped into stages.
# Stages run in sequential order, but jobs within stages run in parallel.
#
# For more information, see: https://docs.github.com/ee/ci/
stages:
- test
- deploy
variables:
NODE_VERSION: "18.17.0"
PM2: "seeds"
deploy-job:
stage: deploy
image: alpine:latest
before_script:
- "command -v ssh-agent >/dev/null || ( apk add --update openssh )"
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan -p $SSH_PORT $SSH_IP >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- ssh -p $SSH_PORT $SSH_USER@$SSH_IP "
. ~/.zshrc &&
cd /home/$SSH_USER/www/$CI_PROJECT_NAME &&
git pull &&
/home/$SSH_USER/.nvm/versions/node/v$NODE_VERSION/bin/pnpm i &&
/home/$SSH_USER/.nvm/versions/node/v$NODE_VERSION/bin/pnpm build &&
pm2 restart $PM2 &&
notifier discord '$CI_PROJECT_TITLE deployed'"
only:
- main