Instantly share code, notes, and snippets.

Embed
What would you like to do?
CircleCI config for building/deploying a GatsbyJS site
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build-job:
docker:
- image: circleci/node:8.9.3
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "yarn.lock" }}
- v1-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "yarn.lock" }}
# build
- run:
name: Compile gatsbyjs site
command: yarn build
- persist_to_workspace:
root: ./
paths:
- public
deploy-staging-job:
docker:
- image: circleci/node:8.9.3
working_directory: ~/repo
steps:
- attach_workspace:
at: ./
- add_ssh_keys
- run:
name: known_hosts sadness
command: ssh-keyscan -H $SITE_SSH_HOST >> ~/.ssh/known_hosts
- run:
name: remove existing files
command: ssh "$SITE_SSH_USER@$SITE_SSH_HOST" "rm -rf /var/www/$STAGING_URL/*"
- run:
name: scp files
command: scp -r public "$SITE_SSH_USER@$SITE_SSH_HOST:/var/www/$STAGING_URL/"
deploy-prod-job:
docker:
- image: circleci/node:8.9.3
working_directory: ~/repo
steps:
- attach_workspace:
at: ./
- add_ssh_keys
- run:
name: known_hosts sadness
command: ssh-keyscan -H $SITE_SSH_HOST >> ~/.ssh/known_hosts
- run:
name: remove existing files
command: ssh "$SITE_SSH_USER@$SITE_SSH_HOST" "rm -rf /var/www/$PROD_URL/*"
- run:
name: scp files
command: scp -r public "$SITE_SSH_USER@$SITE_SSH_HOST:/var/www/$PROD_URL/"
workflows:
version: 2
build_and_deploy:
jobs:
- build-job:
filters:
branches:
only:
- master
- develop
- deploy-staging-job:
filters:
branches:
only:
- develop
requires:
- build-job
- deploy-prod-job:
filters:
branches:
only:
- master
requires:
- build-job
@christianhaller3000

This comment has been minimized.

Show comment
Hide comment
@christianhaller3000

christianhaller3000 Sep 24, 2018

known_hosts sadness, lol 😄

christianhaller3000 commented Sep 24, 2018

known_hosts sadness, lol 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment