-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yml
96 lines (96 loc) · 3.26 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
defaults: &defaults
working_directory: ~/matall.in
version: 2
jobs:
build_and_test:
<<: *defaults
docker:
- image: circleci/ruby:latest-node-browsers
environment:
CHROME_BIN: "/usr/bin/google-chrome"
environment:
NODE_ENV: production
steps:
- checkout
- restore_cache:
key: v1-bundle-{{ checksum "Gemfile.lock" }}
- restore_cache:
key: v1-yarn-{{ checksum "yarn.lock" }}
- run:
name: Install dependencies
command: |
gem install bundler
sudo yarn global add gulp-cli
bundle install --path vendor/bundle
yarn install --no-lockfile
- run:
name: Run linter
command: yarn run lint
- run:
name: Run tests
command: yarn run test
- run:
name: Build
command: |
bundle --path vendor/bundle
if [ ${CIRCLE_BRANCH} == "master" ]; then
JEKYLL_ENV=production yarn run build
else
JEKYLL_ENV=staging yarn run build
fi
- save_cache:
key: v1-bundle-{{ checksum "Gemfile.lock" }}
paths:
- ~/matall.in/vendor/bundle
- save_cache:
key: v1-yarn-{{ checksum "yarn.lock" }}
paths:
- ~/matall.in/node_modules
- persist_to_workspace:
root: .
paths:
- '*'
release:
<<: *defaults
docker:
- image: circleci/node:latest
steps:
- attach_workspace:
at: .
- run:
name: Install dependencies
command: sudo yarn global add gh-release
- run:
name: Publish Release on GitHub
command: gh-release -y
deploy:
<<: *defaults
machine:
enabled: true
steps:
- attach_workspace:
at: .
- run:
name: Deploy to S3
command: |
if [ ${CIRCLE_BRANCH} == "master" ]; then
aws s3 sync --acl public-read dist/ s3://${AWS_BUCKET} --delete --exclude "*" --include "*.html" --include "*.ico" --include "sw.js" --include "manifest.json" --include "*.png" --include "*.txt" --include "*.xml" --include "img/*" --cache-control "max-age=0, public"
aws s3 sync --acl public-read dist/ s3://${AWS_BUCKET} --delete --exclude "*" --include "css/*" --include "js/*" --cache-control "max-age=31536000, public" --expires $(date -d "+1 year" -u +%Y-%m-%dT%H:%M:%SZ)
else
aws s3 sync --acl public-read dist/ s3://${AWS_BUCKET_STAGING} --delete --exclude "*" --include "*.html" --include "*.ico" --include "sw.js" --include "manifest.json" --include "*.png" --include "*.txt" --include "*.xml" --include "img/*" --cache-control "max-age=0, public"
aws s3 sync --acl public-read dist/ s3://${AWS_BUCKET_STAGING} --delete --exclude "*" --include "css/*" --include "js/*" --cache-control "max-age=31536000, public" --expires $(date -d "+1 year" -u +%Y-%m-%dT%H:%M:%SZ)
fi
workflows:
version: 2
build-and-deploy:
jobs:
- build_and_test
- deploy:
requires:
- build_and_test
- release:
requires:
- deploy
filters:
branches:
only: master