1- defaults: &defaults
2- working_directory: ~/code-corps-api
3- docker:
4- - image: circleci/elixir:1.6-node-browsers
5- - image: circleci/postgres:9.4
6- environment:
7- POSTGRES_USER: ubuntu
8- - image: circleci/ruby:2.3
9-
101jobs:
112 build:
12- <<: *defaults
3+ working_directory: ~/code-corps-api
4+ docker:
5+ - image: circleci/elixir:1.6-node-browsers
6+ - image: circleci/postgres:9.4
7+ environment:
8+ POSTGRES_USER: ubuntu
139 steps:
1410 - checkout
1511 - restore_cache:
5046 - save_cache:
5147 key: v1-build-cache
5248 paths: "_build"
53- deploy-staging:
54- <<: *defaults
49+ deploy-remote-development:
50+ working_directory: ~/code-corps-api
51+ docker:
52+ - image: buildpack-deps:trusty
5553 steps:
5654 - checkout
5755 - run:
@@ -66,20 +64,28 @@ jobs:
6664 git push --force git@heroku.com:code-corps-remote-development.git HEAD:refs/heads/master
6765 heroku run "POOL_SIZE=2 mix ecto.migrate" --app code-corps-remote-development
6866 heroku restart --app code-corps-remote-development
67+ deploy-staging:
68+ working_directory: ~/code-corps-api
69+ docker:
70+ - image: buildpack-deps:trusty
71+ steps:
72+ - checkout
73+ - run:
74+ name: Run Heroku setup script
75+ command: bash .circleci/setup-heroku.sh
76+ - add_ssh_keys:
77+ fingerprints:
78+ - "db:3e:d6:de:66:8d:07:55:70:f6:36:0d:e1:11:28:71"
6979 - run:
7080 name: Push to Staging
7181 command: |
7282 git push --force git@heroku.com:code-corps-staging.git HEAD:refs/heads/master
7383 heroku run "POOL_SIZE=2 mix ecto.migrate" --app code-corps-staging
7484 heroku restart --app code-corps-staging
75- - run:
76- name: Update API Docs
77- command: |
78- gem install apiaryio
79- apiary publish --api-name="codecorpsapidevelop" --path ./blueprint/api.apib
80- ./bin/deploy_docs.sh
8185 deploy-production:
82- <<: *defaults
86+ working_directory: ~/code-corps-api
87+ docker:
88+ - image: buildpack-deps:trusty
8389 steps:
8490 - checkout
8591 - run:
@@ -94,17 +100,86 @@ jobs:
94100 git push --force git@heroku.com:code-corps.git HEAD:refs/heads/master
95101 heroku run "POOL_SIZE=2 mix ecto.migrate" --app code-corps
96102 heroku restart --app code-corps
103+ deploy-staging-apiary:
104+ working_directory: ~/code-corps-api
105+ docker:
106+ - image: circleci/ruby:2.4
107+ steps:
108+ - checkout
109+ - run:
110+ name: Install Apiary
111+ command: gem install apiaryio
112+ - run:
113+ name: Deploy API Docs
114+ command: apiary publish --api-name="codecorpsapidevelop" --path ./blueprint/api.apib
115+ deploy-production-apiary:
116+ working_directory: ~/code-corps-api
117+ docker:
118+ - image: circleci/ruby:2.4
119+ steps:
120+ - checkout
121+ - run:
122+ name: Install Apiary
123+ command: gem install apiaryio
124+ - run:
125+ name: Deploy API Docs
126+ command: apiary publish --api-name="codecorpsapi" --path ./blueprint/api.apib
127+ deploy-exdocs:
128+ working_directory: ~/code-corps-api
129+ docker:
130+ - image: circleci/elixir:1.6
131+ steps:
132+ - checkout
133+ - restore_cache:
134+ keys:
135+ - v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
136+ - v1-mix-cache-{{ .Branch }}
137+ - v1-mix-cache
138+ - restore_cache:
139+ keys:
140+ - v1-build-cache-{{ .Branch }}
141+ - v1-build-cache
142+ - run: mix local.hex --force
143+ - run: mix local.rebar
144+ - run: mix deps.get
145+ - add_ssh_keys:
146+ fingerprints:
147+ - "db:3e:d6:de:66:8d:07:55:70:f6:36:0d:e1:11:28:71"
97148 - run:
98- name: Update API Docs
149+ name: Identify as user on GitHub
99150 command: |
100- gem install apiaryio
101- apiary publish --api-name="codecorpsapi" --path ./blueprint/api.apib
151+ git config --global user.email "josh@coderly.com"
152+ git config --global user.name "joshsmith"
153+ - run:
154+ name: Deploy Docs
155+ command: ./bin/deploy_docs.sh
156+ - save_cache:
157+ key: v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
158+ paths: "deps"
159+ - save_cache:
160+ key: v1-mix-cache-{{ .Branch }}
161+ paths: "deps"
162+ - save_cache:
163+ key: v1-mix-cache
164+ paths: "deps"
165+ - save_cache:
166+ key: v1-build-cache-{{ .Branch }}
167+ paths: "_build"
168+ - save_cache:
169+ key: v1-build-cache
170+ paths: "_build"
102171
103172workflows:
104173 version: 2
105174 build-deploy:
106175 jobs:
107176 - build
177+ - deploy-remote-development:
178+ requires:
179+ - build
180+ filters:
181+ branches:
182+ only: develop
108183 - deploy-staging:
109184 requires:
110185 - build
@@ -117,3 +192,21 @@ workflows:
117192 filters:
118193 branches:
119194 only: master
195+ - deploy-staging-apiary:
196+ requires:
197+ - build
198+ filters:
199+ branches:
200+ only: develop
201+ - deploy-production-apiary:
202+ requires:
203+ - build
204+ filters:
205+ branches:
206+ only: master
207+ - deploy-exdocs:
208+ requires:
209+ - build
210+ filters:
211+ branches:
212+ only: develop
0 commit comments