Created
May 5, 2020 21:16
-
-
Save robhrt7/b6f32f4e4d21917e6234b6af8d74c3f2 to your computer and use it in GitHub Desktop.
Example of workflow based/parallel CircleCI build and deploy to Netlify conig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aliases: | |
- &deps | |
- "Dependencies" | |
- &allSites | |
- "reactSummit" | |
- "JSNation" | |
- "JSNationLive" | |
- "NodeDayUK" | |
- &dependencies | |
- checkout | |
# Download and cache dependencies | |
- restore_cache: | |
keys: | |
- v1-dependencies-{{ checksum "frontend/yarn.lock" }} | |
- run: | |
name: install dependencies | |
command: | | |
if [ ! -d "frontend/node_modules" ]; then | |
cd frontend && yarn install | |
fi | |
- save_cache: | |
paths: | |
- frontend/node_modules | |
key: v1-dependencies-{{ checksum "frontend/yarn.lock" }} | |
- persist_to_workspace: | |
root: . | |
paths: | |
- frontend | |
- netlify.toml | |
version: 2 | |
workflows: | |
version: 2 | |
buildBrands: | |
jobs: | |
- "Dependencies" | |
- reactSummit: | |
requires: *deps | |
filters: | |
branches: | |
only: | |
- master | |
- JSNation: | |
requires: *deps | |
filters: | |
branches: | |
only: | |
- master | |
- JSNationLive: | |
requires: *deps | |
filters: | |
branches: | |
only: | |
- master | |
- NodeDayUK: | |
requires: *deps | |
filters: | |
branches: | |
only: | |
- master | |
- deployAllBrandsToNetlify: | |
requires: *allSites | |
filters: | |
branches: | |
only: | |
- master | |
jobs: | |
"Dependencies": | |
docker: | |
- image: circleci/node:10 | |
steps: *dependencies | |
reactSummit: | |
docker: | |
- image: circleci/node:10 | |
steps: | |
- attach_workspace: | |
at: . | |
- run: | |
name: build website | |
command: cd frontend && BRAND_NAME=reactSummit yarn build | |
- persist_to_workspace: | |
root: . | |
paths: | |
- frontend/build/reactSummit | |
JSNation: | |
docker: | |
- image: circleci/node:10 | |
steps: | |
- attach_workspace: | |
at: . | |
- run: | |
name: build website | |
command: cd frontend && BRAND_NAME=JSNation yarn build | |
- persist_to_workspace: | |
root: . | |
paths: | |
- frontend/build/JSNation | |
JSNationLive: | |
docker: | |
- image: circleci/node:10 | |
steps: | |
- attach_workspace: | |
at: . | |
- run: | |
name: build website | |
command: cd frontend && BRAND_NAME=JSNationLive yarn build | |
- persist_to_workspace: | |
root: . | |
paths: | |
- frontend/build/JSNationLive | |
NodeDayUK: | |
docker: | |
- image: circleci/node:10 | |
steps: | |
- attach_workspace: | |
at: . | |
- run: | |
name: build website | |
command: cd frontend && BRAND_NAME=NodeDayUK yarn build | |
- persist_to_workspace: | |
root: . | |
paths: | |
- frontend/build/NodeDayUK | |
deployAllBrandsToNetlify: | |
docker: | |
- image: circleci/node:10 | |
steps: | |
- attach_workspace: | |
at: . | |
- run: | |
name: prepare redirects | |
command: cd frontend && ls && cp _redirects build/ | |
- run: | |
name: deploy to netlify | |
command: | | |
cd frontend | |
yarn netlify deploy --auth $NETLIFY_AUTH_TOKEN --prod --site $NETLIFY_SITE_DEV | |
# This command is being only called directly via API referencing this job | |
buildAndDeployAllBrandsToNetlify: | |
docker: | |
- image: circleci/node:10 | |
steps: | |
- checkout | |
# Download and cache dependencies | |
- restore_cache: | |
keys: | |
- v1-dependencies-{{ checksum "frontend/yarn.lock" }} | |
- run: | |
name: install dependencies | |
command: | | |
if [ ! -d "frontend/node_modules" ]; then | |
cd frontend && yarn install | |
fi | |
- save_cache: | |
paths: | |
- frontend/node_modules | |
key: v1-dependencies-{{ checksum "frontend/yarn.lock" }} | |
- run: | |
name: build all brands | |
command: cd frontend && yarn concurrently "BRAND_NAME=JSNation yarn build" "BRAND_NAME=JSNationLive yarn build" "BRAND_NAME=reactSummit yarn build" "BRAND_NAME=NodeDayUK yarn build" | |
- run: | |
name: prepare redirects | |
command: cd frontend && ls && cp _redirects build/ | |
- run: | |
name: deploy to netlify | |
command: | | |
cd frontend | |
yarn netlify deploy --auth $NETLIFY_AUTH_TOKEN --prod --site $NETLIFY_SITE_PROD | |
curl -X POST -H 'Content-type: application/json' --data '{"text":"All sponsor proposals have been updated on production '$CIRCLE_BUILD_URL'"}' $SLACK_CMS_UPDATE_WEBHOOK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment