Update CircleCI workflow
This commit is contained in:
@@ -3,6 +3,23 @@ defaults: &defaults
|
|||||||
docker:
|
docker:
|
||||||
- image: circleci/node:10.15
|
- image: circleci/node:10.15
|
||||||
|
|
||||||
|
semver-tags: &semver-tags
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /^v.*/
|
||||||
|
branches:
|
||||||
|
ignore: /.*/
|
||||||
|
develop: &develop
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only: develop
|
||||||
|
other-branches: &other-branches
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
ignore:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
|
||||||
version: 2
|
version: 2
|
||||||
jobs:
|
jobs:
|
||||||
install:
|
install:
|
||||||
@@ -41,7 +58,7 @@ jobs:
|
|||||||
- persist_to_workspace:
|
- persist_to_workspace:
|
||||||
root: .
|
root: .
|
||||||
paths: .
|
paths: .
|
||||||
deploy:
|
deploy-prod:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
steps:
|
steps:
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
@@ -51,28 +68,63 @@ jobs:
|
|||||||
command: sudo apt install -y 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 prod
|
||||||
|
- run:
|
||||||
|
name: Purge Cloudflare cache
|
||||||
|
command: bash build/purge_cache.sh
|
||||||
|
deploy-develop:
|
||||||
|
<<: *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 develop
|
||||||
- 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
|
||||||
test-deploy:
|
test:
|
||||||
jobs:
|
jobs:
|
||||||
- install
|
- install: *other-branches
|
||||||
- test:
|
- test:
|
||||||
|
<<: *other-branches
|
||||||
|
requires:
|
||||||
|
- install
|
||||||
|
develop:
|
||||||
|
jobs:
|
||||||
|
- install: *develop
|
||||||
|
- test:
|
||||||
|
<<: *develop
|
||||||
requires:
|
requires:
|
||||||
- install
|
- install
|
||||||
- build:
|
- build:
|
||||||
|
<<: *develop
|
||||||
requires:
|
requires:
|
||||||
- install
|
- install
|
||||||
- deploy:
|
- deploy-develop:
|
||||||
|
<<: *develop
|
||||||
requires:
|
requires:
|
||||||
- build
|
|
||||||
- test
|
- test
|
||||||
filters:
|
- build
|
||||||
branches:
|
prod:
|
||||||
only:
|
jobs:
|
||||||
- master
|
- install: *semver-tags
|
||||||
- develop
|
- test:
|
||||||
|
<<: *semver-tags
|
||||||
|
requires:
|
||||||
|
- install
|
||||||
|
- build:
|
||||||
|
<<: *semver-tags
|
||||||
|
requires:
|
||||||
|
- install
|
||||||
|
- deploy-prod:
|
||||||
|
<<: *semver-tags
|
||||||
|
requires:
|
||||||
|
- test
|
||||||
|
- build
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Ensure target is defined
|
# Ensure target is defined
|
||||||
[ -z "$CIRCLE_BRANCH" ] && { echo >&2 "Error: Build target not defined. Aborting."; exit 1; }
|
[ -z "$1" ] && { 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_$CIRCLE_BRANCH
|
theme/. $SSH_USER@$SSH_IP:~/windycoys_theme_$1
|
||||||
|
|||||||
Reference in New Issue
Block a user