Google Cloud Storage (GCS) Deployment

This page documents deployments using the next major version dpl v2, which currently is in a beta release phase. Please see our blog post for details. The current default version is dpl v1. Check dpl v1 documentation here.

Be sure to read the v2 deployment overview.

Travis CI supports uploading to Google Cloud Storage (GCS).

For a minimal configuration, add the following to your .travis.yml:

  provider: gcs
  key_file: <key_file>
  bucket: <bucket>
  edge: true # opt in to dpl v2

Alternatively, you can use access_key_id and secret_access_key:

  provider: gcs
  access_key_id: <encrypted access_key_id>
  secret_access_key: <encrypted secret_access_key>
  bucket: <bucket>

It is recommended to use a service account key file for authentication, and add it as an encrypted file to your repository. Alternatively, you can find per-user GCS Interoperable Access Keys here.

Status #

Support for deployments to Google Cloud Store is *stable**.

Known options #

Use the following options to further configure the deployment. Either key_file or access_key_id and secret_access_key are required.

key_file Path to a GCS service account key JSON file — type: string
access_key_id GCS Interoperable Access Key ID — secret, type: string
secret_access_key GCS Interoperable Access Secret — secret, type: string
bucket GCS Bucket — required, type: string
local_dir Local directory to upload from — type: string, default: .
upload_dir GCS directory to upload to — type: string
dot_match Upload hidden files starting with a dot — type: boolean
acl Access control to set for uploaded objects — type: string, default: private, known values: private, public-read, public-read-write, authenticated-read, bucket-owner-read, bucket-owner-full-control, see:
detect_encoding HTTP header Content-Encoding to set for files compressed with gzip and compress utilities. — type: boolean
cache_control HTTP header Cache-Control to suggest that the browser cache the file. — type: string, see:
glob type: string, default: **/*

Shared options #

cleanup Clean up build artifacts from the Git working directory before the deployment — type: boolean
run Commands to execute after the deployment finished successfully — type: string or array of strings

Environment variables #

All options can be given as environment variables if prefixed with GCS_.

For example, access_key_id can be given as GCS_ACCESS_KEY_ID=<access_key_id>.

Securing secrets #

Secret option values should be given as either encrypted strings in your build configuration (.travis.yml file) or environment variables in your repository settings.

Environment variables can be set on the settings page of your repository, or using travis env set:

travis env set GCS_ACCESS_KEY_ID <access_key_id>

In order to encrypt option values when adding them to your .travis.yml file use travis encrypt:

travis encrypt <access_key_id>

Or use --add to directly add it to your .travis.yml file. Note that this command has to be run in your repository’s root directory:

travis encrypt --add deploy.access_key_id <access_key_id>

Deploying a specific folder #

You can set specific directory to be uploaded using local-dir option like this:

  provider: gcs
  # ⋮
  local_dir: ./build

Specifiying an ACL #

You can set the acl of your uploaded files via the acl option like this:

  provider: gcs
  # ⋮
  acl: public-read

See the full documentation on Google Cloud.

HTTP cache control #

GCS uploads can optionally set the Cache-Control HTTP header.

Set HTTP header Cache-Control to suggest that the browser cache the file.

  provider: gcs
  # ⋮
  cache_control: max-age=31536000

See the full documentation on Google Cloud.

Pull Requests #

Note that pull request builds skip the deployment step altogether.

See also #