google-github-actions / upload-cloud-storage

A GitHub Action for uploading files to a Google Cloud Storage (GCS) bucket.
https://cloud.google.com/storage
Apache License 2.0
206 stars 49 forks source link

support no-clobber copying #350

Closed mnacharov closed 6 months ago

mnacharov commented 6 months ago

TL;DR

support no-clobber copying, as the gsutil does:

  -n             No-clobber. When specified, existing files or objects at the
                 destination are not replaced. Any items that are skipped
                 by this option are reported as skipped. gsutil
                 performs an additional GET request to check if an item
                 exists before attempting to upload the data. This saves gsutil
                 from retransmitting data, but the additional HTTP requests may make
                 small object transfers slower and more expensive.

Detailed design

as explained in copyFile.js example: the request to copy is aborted if the object's generation number does not match your precondition. So, we can simply set ifGenerationMatch to 0 to copy files that are not in the destination bucket

Additional information

No response

sethvargo commented 6 months ago

Hi @mnacharov

For more advanced options (like rsync), we recommend using setup-gcloud and using gcloud storage or gsutil directly instead.