Skip to content

Instantly share code, notes, and snippets.

@ssheduardo
Last active November 30, 2019 20:21
Show Gist options
  • Save ssheduardo/e967aef2ec3423bad50b5a64f1486f61 to your computer and use it in GitHub Desktop.
Save ssheduardo/e967aef2ec3423bad50b5a64f1486f61 to your computer and use it in GitHub Desktop.
Deploy react to server with gitlab
build site:
image: node:12.13.0-slim
stage: build
before_script:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
- yarn install --pure-lockfile --cache-folder .yarn
cache:
paths:
- node_modules/
- .yarn
script:
- yarn build
artifacts:
expire_in: 1 week
paths:
- build
deploy:
image: alpine
stage: deploy
script:
- apk add --no-cache rsync openssh
- mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- rsync -rav --delete build/ user@server.com:/your/project/path/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment