Clearing my Google Cloud Storage(GCS) bucket before travis deploy (using Docker also)

This is my .travis.yml :

language: node_js
node_js:
  - "node"

cache: npm
script: npm run build

deploy:
  provider: gcs
  access_key_id: $ACCESS_KEY_ID
  secret_access_key: $SECRET_ACCESS_KEY
  bucket: $BUCKET_NAME
  skip_cleanup: true
  local_dir: dist
  cache_control: "no-cache,max-age=0"
  on:
    branch: master

I’m running a vue and React project inside Docker and I build files with hashed filenames. So everytime I deployed, the new files such as app.56785678.js had been deployed to my bucket. The previous version (like app.12341234.js ) is still in the GCS bucket. Any ideas?

Hey @SolarUltima,

When you deploy to a folder in dist, so for example in this case, the documentation says that it will be cleaned up unless skip_cleanup from reading your .travis.yml is true, which is your case. Please, try:

deploy:
  provider: gcs
  access_key_id: $ACCESS_KEY_ID
  secret_access_key: $SECRET_ACCESS_KEY
  bucket: $BUCKET_NAME
  skip_cleanup: false
  local_dir: dist
  cache_control: "no-cache,max-age=0"
  on:
    branch: master

You’ll notice the following:

skip_cleanup: false

Instead of what you had before which was:

skip_cleanup: true
1 Like

doing

skip_cleanup: false indeed worked, also there was one line I changed in Dockerfile, thanks @Montana a hero around here!

No problem @SolarUltima,

A hero, not sure about that but I’m glad I can help out a lot! If you need anything else, as per usual please don’t hesitate to post back.

-Montana
Travis CI Staff

Imprint