You can easily test, build, and/or deploy your website using a continuous integration (CI) system. CI systems remove extra steps from your project's lifecycle and allow you to save time on repetitive tasks.

The combination of GitHub, CI, Grow, and a static hosting service such as Google Cloud Storage or Amazon S3 allow you and your team to collaborate on Git and keep your site automatically up to date – without ever having to run a deploy command.

In fact, this is exactly how this documentation is deployed.

For security, when doing deployments from CI the CI providers allow you to set environment variables in the UI that can be used in the build but not committed to the repository. Your build steps can make use of these environment variables to authenticate to external services such as Google Cloud Storage or Amazon S3 when deploying.

Using Circle CI for automatic deploys

Circle CI 2.0 makes use of docker images which can produce faster builds. Grow has a docker image (grow/base) that comes preloaded with grow and some of the common utilities used to build grow sites (like npm and gcloud).

  1. Set up your deployment (both the host and the configuration in podspec.yaml)
  2. Connect your GitHub repo with Circle CI
  3. Configure Circle CI

To configure Circle CI, add a .circleci/config.yml file in your repository's root. Any required access keys can be configured as secure environment variables in the settings section of your Circle CI project.

version: 2
jobs:
build:
working_directory: ~/grow
docker:
- image: grow/base:latest
steps:
- checkout
- restore_cache:
keys:
- &cache_key grow-cache-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "extensions.txt" }}
- run:
name: Grow Install
command: grow install
- save_cache:
key: *cache_key
paths:
- extensions
- node_modules
- run:
name: Test Build
command: grow build
- run:
name: Deploy to Prod
command: |
if [ "$CIRCLE_BRANCH" == "master" ] && [ "$CIRCLE_PULL_REQUEST" == "" ] ; then
grow deploy --noconfirm grow.io ;
fi
view raw config.yml hosted with ❤ by GitHub

Complex Parallel Builds

For large sites using a CI service it is possible to break up a build into sharded builds that split the routes then re-combine the build results in a "fan-in" deploy.

version: 2
shortcuts:
restore_cache: &restore_cache
keys:
- &cache_key cache-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
install_grow: &install_grow
name: Grow Install
command: grow install
save_cache: &save_cache
key: *cache_key
paths:
- node_modules
persist: &persist
root: ~/grow
paths:
- build/
jobs:
build-a:
working_directory: ~/grow
docker:
- image: grow/base:master
steps:
- checkout
- restore_cache:
<<: *restore_cache
- run:
<<: *install_grow
- save_cache:
<<: *save_cache
- run:
name: Grow Build
# Deployment is used to build with a specific deployment environment.
# Should be updated to use the name of the deployment from podspec.
# Can be removed if you do not use a deployment environment.
command: grow build --shards=3 --shard=1 --deployment=prod
- persist_to_workspace:
<<: *persist
build-b:
working_directory: ~/grow
docker:
- image: grow/base:master
steps:
- checkout
- restore_cache:
<<: *restore_cache
- run:
<<: *install_grow
- save_cache:
<<: *save_cache
- run:
name: Grow Build
command: grow build --shards=3 --shard=2 --deployment=prod
- persist_to_workspace:
<<: *persist
build-c:
working_directory: ~/grow
docker:
- image: grow/base:master
steps:
- checkout
- restore_cache:
<<: *restore_cache
- run:
<<: *install_grow
- save_cache:
<<: *save_cache
- run:
name: Grow Build
command: grow build --shards=3 --shard=3 --deployment=prod
- persist_to_workspace:
<<: *persist
deploy:
working_directory: ~/grow
docker:
- image: grow/base:master
steps:
- attach_workspace:
at: ~/grow
- run:
name: Deploy
command: grow deploy prod -np --work-dir=build
workflows:
version: 2
build_and_deploy:
jobs:
- build-a
- build-b
- build-c
- deploy:
requires:
- build-a
- build-b
- build-c
view raw config.yml hosted with ❤ by GitHub

Using Travis CI for automatic deploys

  1. Set up your deployment (both the host and the configuration in podspec.yaml).
  2. Connect your GitHub repo with Travis CI.
  3. Configure Travis CI.

To configure Travis CI, add a .travis.yml file in your repository's root. Any required access keys can be configured as secure environment variables in the settings section of your Travis CI project.

language: python
python:
- 2.7
branches:
  only:
  - master
cache: pip
install: pip install grow
script: grow deploy --noconfirm grow.io