Google Cloud Storage Deployment
This page documents deployments using dpl v1 which is currently the legacy version. The dpl v2 is released, and we recommend useig it. Please see our blog post for details. dpl v2 documentation can be found here.
Travis CI supports uploading to Google Cloud Storage (GCS).
A minimal configuration is:
deploy:
provider: gcs
access_key_id: "GCS Interoperable Access Key ID"
secret_access_key: "GCS Interoperable Access Secret"
bucket: "GCS Bucket"
This example is almost certainly not ideal, as you probably want to upload your built binaries and documentation. Set skip_cleanup
to true
to prevent Travis CI from deleting your build artifacts.
deploy:
provider: gcs
access_key_id: "GCS Interoperable Access Key ID"
secret_access_key: "GCS Interoperable Access Secret"
bucket: "GCS Bucket"
skip_cleanup: true
You can find your GCS Interoperable Access Keys here. It is recommended to encrypt that key. Assuming you have the Travis CI command line client installed, you can do it like this:
travis encrypt --add deploy.secret_access_key
You will be prompted to enter your api key on the command line.
You can also have the travis
tool set up everything for you:
travis setup gcs
Keep in mind that the above command has to run in your project directory, so it can modify the .travis.yml
for you.
Set GCS via ACL #
You can set the ACL of your uploaded files via the acl
option like this:
deploy:
provider: gcs
access_key_id: "GCS Interoperable Access Key ID"
secret_access_key: "GCS Interoperable Access Secret"
bucket: "GCS Bucket"
skip_cleanup: true
acl: public-read
Valid ACL values are: private
, public-read
, public-read-write
, authenticated-read
, bucket-owner-read
, bucket-owner-full-control
. The ACL defaults to private
.
See the full documentation on Google Cloud.
Deploy Specific Folders #
You can set a specific directory to be uploaded using local-dir
option like this:
deploy:
provider: gcs
access_key_id: "GCS Interoperable Access Key ID"
secret_access_key: "GCS Interoperable Access Secret"
bucket: "GCS Bucket"
skip_cleanup: true
acl: public-read
local-dir: directory-name
If the directory-name
is generated during build process, it will be deleted (cleaned up) before deploying, unless skip_cleanup
is set to true.
Conditional releases #
You can deploy only when certain conditions are met.
See Conditional Releases with on:
.
Setting a Content-Encoding Header #
GCS uploads can optionally set the HTTP header Content-Encoding
.
This header allows files to be sent compressed while retaining file extensions and
the associated MIME types.
To enable this feature, add:
deploy:
provider: gcs
...
detect_encoding: true # <== default is false
If the file is compressed with gzip
or compress
, it will be uploaded with
the appropriate header.
HTTP cache control #
GCS uploads can optionally set the Cache-Control
HTTP header.
Set the HTTP header Cache-Control
to suggest that the browser cache the file. Defaults to no-cache
. Valid options are no-cache
, no-store
, max-age=<seconds>
, s-maxage=<seconds> no-transform
, public
, private
.
deploy:
provider: gcs
...
cache_control: "max-age=31536000"
See the full documentation on Google Cloud.