Add CI/CD

This commit is contained in:
Вячеслав 2025-04-23 17:13:11 +00:00
parent 8be6543a3c
commit 60f89fc780
4 changed files with 134 additions and 7 deletions

View file

@ -0,0 +1,37 @@
stages:
- build
- test
- deploy
frontend-build-job:
image: node:20-alpine
stage: build
script:
- cd SurveyFrontend
- npm install
- npm run build
artifacts:
paths:
- SurveyFrontend/dist
expire_in: 1 hour
frontend-test-job:
image: alpine:latest
stage: test
script:
- echo "Here we would run some tests if I knew how to use them"
frontend-deploy-job:
image: alpine:latest
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
before_script:
- apk add --no-cache openssh
- mkdir -p ~/.ssh
- echo "$DEPLOY_KEY" | base64 -d > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
script:
- echo "Deploying frontend to $DEPLOY_HOST"
- scp -r SurveyFrontend/dist/* $DEPLOY_USER@$DEPLOY_HOST:$FRONTEND_DEPLOY_PATH