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

Inconsistent path processing for `.gcloudignore` #357

Open eddielin0926 opened 2 months ago

eddielin0926 commented 2 months ago

TL;DR

The issue pertains to inconsistent path processing when the given path is treated as the root directory, but the top-level .gcloudignore is utilized. Therefore, the path in .gcloudignore is concatenated with the given path variable.

Expected behavior

The paths listed in .gcloudignore should be calculated from the path of .gcloudignore.

Observed behavior

No response

Action YAML

- id: 'upload-file'
  uses: 'google-github-actions/upload-cloud-storage@v2'
  with:
    path: '/path/to/file'
    destination: 'bucket-name'
    process_gcloudignore: true

Log output

No response

Additional information

No response

sethvargo commented 2 months ago

How does gcloud behave here? I believe we mirrored the same functionality.

eddielin0926 commented 2 months ago

How does gcloud behave here? I believe we mirrored the same functionality.

gcloud does not always use the top-level .gcloudignore. It uses the .gcloudignore located in the given directory.

Here is an example.

$ mkdir -p example/upload && cd example
$ echo "upload/a.txt" > .gcloudignore
$ echo "b.txt" > upload/.gcloudignore
$ touch upload/a.txt upload/b.txt
$ gcloud meta list-files-for-upload
.gcloudignore
upload/.gcloudignore
upload/b.txt
$ gcloud meta list-files-for-upload upload
.gcloudignore
a.txt