Optimize circleci build

This commit is contained in:
2019-01-09 14:57:58 +00:00
parent d302d944fc
commit b3a1469312
2 changed files with 50 additions and 17 deletions

View File

@@ -1,48 +1,76 @@
defaults: &defaults
working_directory: ~/tmp/windycoys
docker:
- image: circleci/node:10.15
version: 2
jobs:
test:
docker:
- image: circleci/node:10.0.0
install:
<<: *defaults
steps:
- attach_workspace:
at: ~/tmp/windycoys
- checkout
- run:
name: Install dependencies
command: npm install
- persist_to_workspace:
root: .
paths: .
test:
<<: *defaults
steps:
- attach_workspace:
at: ~/tmp/windycoys
- run:
name: Run tests
command: npm test
build-latest:
docker:
- image: circleci/node:10.0.0
build:
<<: *defaults
steps:
- checkout
- run:
name: Install rsync
command: sudo apt install -y rsync
- run:
name: Install dependencies
command: npm install
- attach_workspace:
at: ~/tmp/windycoys
- run:
name: Build CSS and JavaScript
command: npm run build
- run:
name: Generate timestamp
command: bash build/generate_timestamp.sh
- persist_to_workspace:
root: .
paths: .
deploy:
<<: *defaults
steps:
- attach_workspace:
at: ~/tmp/windycoys
- run:
name: Install rsync
command: sudo apt install -y rsync
- run:
name: Deploy theme
command: bash build/deploy.sh
- run:
name: Purge Cloudflare cache
command: bash build/purge_cache.sh
workflows:
version: 2
build-latest:
test-deploy:
jobs:
- test
- build-latest:
- install
- test:
requires:
- install
- build:
requires:
- install
- deploy:
requires:
- build
- test
filters:
branches:
only:
- master
- develop

View File

@@ -1,10 +1,15 @@
#!/usr/bin/env bash
# Ensure target is defined
[ -z "$CIRCLE_BRANCH" ] && { echo >&2 "Error: Build target not defined. Aborting."; exit 1; }
# Test rsync is installed and ENV variables are set
hash rsync 2>/dev/null || { echo >&2 "Error: rsync is not installed. Aborting."; exit 1; }
[ -z "$SSH_IP" ] && { echo >&2 "Error: SSH_IP is missing. Aborting."; exit 1; }
[ -z "$SSH_USER" ] && { echo >&2 "Error: SSH_USER is missing. Aborting."; exit 1; }
echo "Deploying to $CIRCLE_BRANCH"
# Deploy theme with rsync
rsync -e "ssh -o StrictHostKeyChecking=no" -avzuh --progress \
theme/. $SSH_USER@$SSH_IP:~/windycoys_theme
theme/. $SSH_USER@$SSH_IP:~/windycoys_theme_$CIRCLE_BRANCH