Last active
September 10, 2020 04:54
-
-
Save lazzyms/92211b52617672d936002a860e30170f to your computer and use it in GitHub Desktop.
Deploy React build with gitlab-ci
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: node:10 | |
cache: | |
paths: | |
- node_modules/ | |
before_script: | |
- apt-get update -qq && apt install -y openssh-client openssh-server | |
- mkdir -p ~/.ssh | |
- echo -e "$SSH_PRIVATE_KEY" > ~/deploy.pem | |
- chmod 400 ~/deploy.pem | |
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' | |
deploy_production: | |
only: | |
refs: | |
- master | |
stage: deploy | |
environment: | |
name: production | |
script: | |
- npm install | |
- REACT_APP_SERVER=production CI=true npm run build | |
- scp -i ~/deploy.pem -r build/* $USER_NAME@$SERVER_IP:/var/www/html/provider | |
deploy_staging: | |
only: | |
refs: | |
- staging | |
stage: deploy | |
environment: | |
name: staging | |
script: | |
- npm install | |
- REACT_APP_SERVER=staging CI=false npm run build | |
- scp -i ~/deploy.pem -r build/* $USER_NAME@$SERVER_IP:/var/www/html/staging-provider |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment