Updating .gitlab-ci.yml
This commit is contained in:
@@ -1,19 +1,45 @@
|
||||
image: node:latest
|
||||
|
||||
stages:
|
||||
- build
|
||||
- deploy
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- node_modules/
|
||||
|
||||
|
||||
before_script:
|
||||
- apt-get update -y && apt-get upgrade -y
|
||||
- apt-get install rsync -y
|
||||
- mkdir -p ~/.ssh
|
||||
- echo -e "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||
- chmod 600 ~/.ssh/id_rsa
|
||||
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
|
||||
|
||||
test_execution:
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script:
|
||||
- npm install
|
||||
- npm run build
|
||||
- rsync -rvz build ryuuji@142.93.158.54:~
|
||||
artifacts:
|
||||
paths:
|
||||
- build/
|
||||
|
||||
deploy:
|
||||
stage: deploy
|
||||
script:
|
||||
## Install ssh-agent if not already installed
|
||||
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )'
|
||||
|
||||
## Run ssh-agent (inside the build environment)
|
||||
- eval $(ssh-agent -s)
|
||||
|
||||
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
|
||||
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
||||
|
||||
## Create the SSH directory and give it the right permissions
|
||||
- mkdir -p ~/.ssh
|
||||
- chmod 700 ~/.ssh
|
||||
|
||||
## Use ssh-keyscan to scan the keys of the private server
|
||||
- ssh-keyscan "$REMOTE_HOST" >> ~/.ssh/known_hosts
|
||||
- chmod 644 ~/.ssh/known_hosts
|
||||
|
||||
## Sync the project to the deploy route
|
||||
- apt-get install rsync -y
|
||||
- rsync -rvz build "$DEPLOY_ROUTE"
|
||||
|
||||
Reference in New Issue
Block a user