Skip to content

Instantly share code, notes, and snippets.

@e200
Created December 3, 2020 11:30
Show Gist options
  • Save e200/83179a94eb61a5f0e7ae51381a72185d to your computer and use it in GitHub Desktop.
Save e200/83179a94eb61a5f0e7ae51381a72185d to your computer and use it in GitHub Desktop.
Frontend deploy
image: debian:latest
stages:
- build
cache:
untracked: true
key: "$CI_BUILD_REF_NAME"
paths:
- node_modules
- .yarn
build:
stage: build
only:
- tags
except:
- master
before_script:
- apt update && apt upgrade -y && apt install curl gnupg2 sshpass zip -y
- apt remove cmdtest yarn -y
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
- apt update
- apt install yarn -y
script:
- yarn config set cache-folder .yarn
- yarn install
- yarn build --prod
- zip -r dist.zip ./dist
- sshpass -e ssh -o "StrictHostKeyChecking=no" $SSH_USER@$SSH_SERVER rm -rf $SSH_DEPLOY_DESTINATION/* && mkdir -p $SSH_DEPLOY_DESTINATION
- sshpass -e scp -o "StrictHostKeyChecking=no" ./dist.zip $SSH_USER@$SSH_SERVER:$SSH_DEPLOY_DESTINATION
- sshpass -e ssh -o "StrictHostKeyChecking=no" $SSH_USER@$SSH_SERVER cd $SSH_DEPLOY_DESTINATION && unzip -u ./dist.zip && mv ./dist/* . && rm -rf ./dist dist.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment