|
| 1 | +jobs: |
| 2 | + build: |
| 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 |
| 9 | + steps: |
| 10 | + - checkout |
| 11 | + - restore_cache: |
| 12 | + keys: |
| 13 | + - v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }} |
| 14 | + - v1-mix-cache-{{ .Branch }} |
| 15 | + - v1-mix-cache |
| 16 | + - restore_cache: |
| 17 | + keys: |
| 18 | + - v1-build-cache-{{ .Branch }} |
| 19 | + - v1-build-cache |
| 20 | + - run: |
| 21 | + name: Install PostgreSQL Client (for pg_dump, happening as part of ecto.migrate) |
| 22 | + command: sudo apt install postgresql-client |
| 23 | + - run: mix local.hex --force |
| 24 | + - run: mix local.rebar |
| 25 | + - run: mix deps.get |
| 26 | + - run: |
| 27 | + name: Run test suite and maybe report coverage |
| 28 | + command: | |
| 29 | + if [ ${CIRCLE_PR_USERNAME} ]; then |
| 30 | + MIX_ENV=test mix test; |
| 31 | + else |
| 32 | + MIX_ENV=test mix coveralls.circle --include acceptance:true; |
| 33 | + fi |
| 34 | + - save_cache: |
| 35 | + key: v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }} |
| 36 | + paths: "deps" |
| 37 | + - save_cache: |
| 38 | + key: v1-mix-cache-{{ .Branch }} |
| 39 | + paths: "deps" |
| 40 | + - save_cache: |
| 41 | + key: v1-mix-cache |
| 42 | + paths: "deps" |
| 43 | + - save_cache: |
| 44 | + key: v1-build-cache-{{ .Branch }} |
| 45 | + paths: "_build" |
| 46 | + - save_cache: |
| 47 | + key: v1-build-cache |
| 48 | + paths: "_build" |
| 49 | + deploy-remote-development: |
| 50 | + working_directory: ~/code-corps-api |
| 51 | + docker: |
| 52 | + - image: buildpack-deps:trusty |
| 53 | + steps: |
| 54 | + - checkout |
| 55 | + - run: |
| 56 | + name: Run Heroku setup script |
| 57 | + command: bash .circleci/setup-heroku.sh |
| 58 | + - add_ssh_keys: |
| 59 | + fingerprints: |
| 60 | + - "48:a0:87:54:ca:75:32:12:c6:9e:a2:77:a4:7a:08:a4" |
| 61 | + - run: |
| 62 | + name: Push to Remote Development |
| 63 | + command: | |
| 64 | + git push --force [email protected]:code-corps-remote-development.git HEAD:refs/heads/master |
| 65 | + heroku run "POOL_SIZE=2 mix ecto.migrate" --app code-corps-remote-development |
| 66 | + 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" |
| 79 | + - run: |
| 80 | + name: Push to Staging |
| 81 | + command: | |
| 82 | + git push --force [email protected]:code-corps-staging.git HEAD:refs/heads/master |
| 83 | + heroku run "POOL_SIZE=2 mix ecto.migrate" --app code-corps-staging |
| 84 | + heroku restart --app code-corps-staging |
| 85 | + deploy-production: |
| 86 | + working_directory: ~/code-corps-api |
| 87 | + docker: |
| 88 | + - image: buildpack-deps:trusty |
| 89 | + steps: |
| 90 | + - checkout |
| 91 | + - run: |
| 92 | + name: Run Heroku setup script |
| 93 | + command: bash .circleci/setup-heroku.sh |
| 94 | + - add_ssh_keys: |
| 95 | + fingerprints: |
| 96 | + - "48:a0:87:54:ca:75:32:12:c6:9e:a2:77:a4:7a:08:a4" |
| 97 | + - run: |
| 98 | + name: Deploy Master to Heroku Production |
| 99 | + command: | |
| 100 | + git push --force [email protected]:code-corps.git HEAD:refs/heads/master |
| 101 | + heroku run "POOL_SIZE=2 mix ecto.migrate" --app code-corps |
| 102 | + 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" |
| 148 | + - run: |
| 149 | + name: Identify as user on GitHub |
| 150 | + command: | |
| 151 | + git config --global user.email "[email protected]" |
| 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" |
| 171 | + |
| 172 | +workflows: |
| 173 | + version: 2 |
| 174 | + build-deploy: |
| 175 | + jobs: |
| 176 | + - build |
| 177 | + - deploy-remote-development: |
| 178 | + requires: |
| 179 | + - build |
| 180 | + filters: |
| 181 | + branches: |
| 182 | + only: develop |
| 183 | + - deploy-staging: |
| 184 | + requires: |
| 185 | + - build |
| 186 | + filters: |
| 187 | + branches: |
| 188 | + only: develop |
| 189 | + - deploy-production: |
| 190 | + requires: |
| 191 | + - build |
| 192 | + filters: |
| 193 | + branches: |
| 194 | + 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