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

View File

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