Skip to content

Commit d9ab2ac

Browse files
chore: Update deployment script to use Node.js 20.15.0 and optimize build process
1 parent 5e2481b commit d9ab2ac

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

.gitlab-ci.yml

+22-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
# A pipeline is composed of independent jobs that run scripts, grouped into stages.
22
# Stages run in sequential order, but jobs within stages run in parallel.
33
#
4-
# For more information, see: https://docs.github.com/ee/ci/
4+
# For more information, see: https://docs.gitlab.com/ee/ci/
55

66
stages:
7-
- test
87
- deploy
98

10-
variables:
11-
NODE_VERSION: 18.17.0
12-
139
deploy-job:
1410
stage: deploy
15-
image: alpine:latest
11+
image: node:20.15.0
1612
before_script:
1713
- "command -v ssh-agent >/dev/null || ( apk add --update openssh )"
1814
- eval $(ssh-agent -s)
@@ -21,16 +17,30 @@ deploy-job:
2117
- chmod 700 ~/.ssh
2218
- ssh-keyscan -p $SSH_PORT $SSH_IP >> ~/.ssh/known_hosts
2319
- chmod 644 ~/.ssh/known_hosts
20+
- echo "Installing dependencies..."
21+
- apt-get update -qq && apt-get install -y -qq sshpass
22+
- apt-get install -y -qq rsync
23+
- echo "Setup..."
24+
- git clone https://gitlab.com/kiwilan/feedrender.git
25+
- cd feedrender
26+
- scp -P $SSH_PORT $SSH_USER@$SSH_IP:/var/www/$CI_PROJECT_NAME/.env .env
27+
- npm install -g pnpm
28+
- pnpm i
29+
- echo "Building..."
30+
- pnpm build
31+
- echo "Deploying..."
2432
script:
33+
- rsync -azPhhr -e "ssh -p $SSH_PORT" dist $SSH_USER@$SSH_IP:/var/www/$CI_PROJECT_NAME/dist-$CI_JOB_ID
2534
- ssh -p $SSH_PORT $SSH_USER@$SSH_IP "
2635
. ~/.zshrc &&
27-
cd /home/$SSH_USER/www/$CI_PROJECT_NAME &&
36+
cd /var/www/$CI_PROJECT_NAME &&
2837
git pull &&
29-
/home/$SSH_USER/.nvm/versions/node/v$NODE_VERSION/bin/pnpm i &&
30-
/home/$SSH_USER/.nvm/versions/node/v$NODE_VERSION/bin/pnpm build &&
31-
docker compose build --no-cache &&
32-
docker compose down &&
33-
docker compose up -d &&
38+
docker cp dist-$CI_JOB_ID $DOCKER_CONTAINER:/usr/src/app/ &&
39+
docker exec $DOCKER_CONTAINER rm -rf dist &&
40+
docker exec $DOCKER_CONTAINER mv dist-$CI_JOB_ID/dist dist &&
41+
docker exec $DOCKER_CONTAINER rm -rf dist-$CI_JOB_ID &&
42+
docker restart $DOCKER_CONTAINER &&
43+
rm -rf dist-$CI_JOB_ID &&
3444
notifier discord '$CI_PROJECT_TITLE deployed'"
3545
only:
3646
- main

0 commit comments

Comments
 (0)