Skip to content

Instantly share code, notes, and snippets.

@WincerChan
Created June 14, 2018 12:18
Show Gist options
  • Save WincerChan/04b5e1ee8a1fbc8bc2e078d2c354bd7b to your computer and use it in GitHub Desktop.
Save WincerChan/04b5e1ee8a1fbc8bc2e078d2c354bd7b to your computer and use it in GitHub Desktop.
CircleCI 配置文件
# 设置默认 image
defaults: &defaults
docker:
- image: circleci/node:10.4.0
version: 2
jobs:
build:
# 导入默认设置
<<: *defaults
steps:
- checkout
- run:
name: Install Dependence
command: |
yarn install && yarn build
- save_cache:
key: meme-v1-{{ checksum "package.json" }}
paths:
- "build"
deploy:
<<: *defaults
steps:
- checkout
- run:
name: Update System
command: |
sudo apt-get update && sudo apt-get install rsync
- restore_cache:
keys:
- meme-v1-{{ checksum "package.json" }}
- deploy:
name: Deploy via ssh
# 仅在 master 分支才部署
command: |
mkdir -p ~/.ssh
touch ~/.ssh/known_hosts
{ ssh-keyscan $SSH_IP 2> /dev/null; } >> ~/.ssh/known_hosts
if [ ${CIRCLE_BRANCH} = "master" ];then
rsync -az -v --delete -e ssh build/* $SSH_USER@$SSH_IP:/data/www/meme/
else
echo "Not master branch"
fi
workflows:
version: 2
Meme-CI:
jobs:
- build
- deploy:
requires:
- build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment