Skip to content

Instantly share code, notes, and snippets.

@miukki
Created May 2, 2019 04:14
Show Gist options
  • Save miukki/da4fc736b573603b8c882045650a99b4 to your computer and use it in GitHub Desktop.
Save miukki/da4fc736b573603b8c882045650a99b4 to your computer and use it in GitHub Desktop.
Deploy to private server by using cirkcle CI config with connect to SSH
version: 2
jobs:
build:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: yarn
- run: yarn build
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
# - run: yarn test
- persist_to_workspace:
root: ~/repo
paths:
- build
- ssh_pem
deploy:
machine:
enabled: true
working_directory: ~/repo
steps:
- attach_workspace:
at: ./workspace
- add_ssh_keys:
fingerprints:
- "e4:aa:17:b5:4f:6f:6b:f9:72:ac:3f:de:f9:c4:d6:c5"
- run:
name: change file permession
command: chmod 600 ./workspace/ssh_pem/id_rsa
- run:
name: remove existing files
command: ssh -i ./workspace/ssh_pem/id_rsa "[email protected]" "rm -rf /var/melody/homepage2/*"
- run:
name: scp files
# command: find . -name "id_rsa"
command: scp -i ./workspace/ssh_pem/id_rsa -r ./workspace/build/* [email protected]:/var/melody/homepage2/
workflows:
version: 2
build-and-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: develop
version: 2
jobs:
build:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: yarn
- run: yarn build
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
# - run: yarn test
- persist_to_workspace:
root: ~/repo
paths:
- build
- ssh_pem
deploy:
machine:
enabled: true
working_directory: ~/repo
steps:
- attach_workspace:
at: ./workspace
- add_ssh_keys:
fingerprints:
- "e4:aa:17:b5:4f:6f:6b:f9:72:ac:3f:de:f9:c4:d6:c5"
- run:
name: change file permession
command: chmod 600 ./workspace/ssh_pem/id_rsa
- run:
name: remove existing files
command: ssh -i ./workspace/ssh_pem/id_rsa "[email protected]" "rm -rf /var/melody/homepage2/*"
- run:
name: scp files
# command: find . -name "id_rsa"
command: scp -i ./workspace/ssh_pem/id_rsa -r ./workspace/build/* [email protected]:/var/melody/homepage2/
workflows:
version: 2
build-and-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment