Skip to content

Instantly share code, notes, and snippets.

@jmn
Last active May 27, 2023 04:20
Show Gist options
  • Save jmn/91404be68b14c59c7d86157b40e98d0c to your computer and use it in GitHub Desktop.
Save jmn/91404be68b14c59c7d86157b40e98d0c to your computer and use it in GitHub Desktop.
CircleCI build and deploy via Rsync SSH in two steps
version: 2.1
executors:
my-executor:
docker:
- image: circleci/node:8
working_directory: /tmp
jobs:
build:
executor: my-executor
working_directory: ~/r
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
# run tests!
- run: npm test
- run: npm run build --prod
- persist_to_workspace:
root: "~"
paths:
- r/build
deploy:
executor: my-executor
steps:
- attach_workspace:
at: ./build
- run: mkdir ~/.ssh
- run: ssh-keyscan $SSH_HOST >> ~/.ssh/known_hosts
- run: sudo apt install rsync
- run:
name: Deploy Over SSH
command: |
rsync -avz -e "ssh" --progress build $SSH_USER@$SSH_HOST:build
# scp -r build/* $SSH_USER@$SSH_HOST:build
- run: ssh $SSH_USER@$SSH_HOST 'chmod -R 755 ~/build'
workflows:
version: 2.1
build-and-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment