Skip to content

Commit

Permalink
feat(push-to-gcs): allow setting 'predefinedAcl' on objects when uplo…
Browse files Browse the repository at this point in the history
…ading (#193)

* feat(push-to-gcs): Allow setting 'predefinedAcl' on objects when uploading

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update actions/push-to-gcs/README.md

Co-authored-by: Iain Lane <[email protected]>

* Use named reference-style links

---------

Co-authored-by: twu <[email protected]>
Co-authored-by: Iain Lane <[email protected]>
  • Loading branch information
3 people authored Jul 22, 2024
1 parent eb2d757 commit 97e6191
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
27 changes: 19 additions & 8 deletions actions/push-to-gcs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ jobs:
path: file.txt
environment: "dev" # Can be dev/prod (defaults to dev)

# Upload a single file and apply a predefined ACL. See `predefinedAcl` for options.
- uses: grafana/shared-workflows/actions/push-to-gcs@main
with:
bucket: ${{ steps.login-to-gcs.outputs.bucket }}
path: file.txt
predefinedAcl: projectPrivate
environment: "dev"

# Here are 3 equivalent statements to upload a single file and its parent directory to the bucket root
- uses: grafana/shared-workflows/actions/push-to-gcs@main
with:
Expand Down Expand Up @@ -98,17 +106,20 @@ jobs:
## Inputs
| Name | Type | Description |
| ------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bucket` | String | (Required) Name of bucket to upload to. Can be gathered from `login-to-gcs` action. |
| `path` | String | (Required) The path to a file or folder inside the action's filesystem that should be uploaded to the bucket. You can specify either the absolute path or the relative path from the action. |
| `bucket_path` | String | Bucket path where objects will be uploaded. Default is the bucket root. |
| `environment` | String | Environment for pushing artifacts (can be either dev or prod). |
| `glob` | String | Glob pattern. |
| `parent` | String | Whether parent dir should be included in GCS destination. Dirs included in the `glob` statement are unaffected by this setting. |
| Name | Type | Description |
| --------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bucket` | String | (Required) Name of bucket to upload to. Can be gathered from `login-to-gcs` action. |
| `path` | String | (Required) The path to a file or folder inside the action's filesystem that should be uploaded to the bucket. You can specify either the absolute path or the relative path from the action. |
| `bucket_path` | String | Bucket path where objects will be uploaded. Default is the bucket root. |
| `environment` | String | Environment for pushing artifacts (can be either dev or prod). |
| `glob` | String | Glob pattern. |
| `parent` | String | Whether parent dir should be included in GCS destination. Dirs included in the `glob` statement are unaffected by this setting. |
| `predefinedAcl` | String | Predefined ACL applied to the uploaded objects. Default is `projectPrivate`. See [Google Documentation][gcs-docs-upload-options] for a list of available options. |

## Outputs

| Name | Type | Description |
| ---------- | ------ | -------------------------------------------------- |
| `uploaded` | String | The list of files that were successfully uploaded. |

[gcs-docs-upload-options]: https://googleapis.dev/nodejs/storage/latest/global.html#UploadOptions
6 changes: 6 additions & 0 deletions actions/push-to-gcs/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ inputs:
Whether parent dir should be included in GCS destination.
Dirs included in the `glob` statement are unaffected by this setting.
default: "true"
predefinedAcl:
description: |
Apply a predefined set of access controls to the file(s).
Default is projectPrivate (See https://googleapis.dev/nodejs/storage/latest/global.html#UploadOptions)
default: projectPrivate

outputs:
uploaded:
Expand Down Expand Up @@ -82,4 +87,5 @@ runs:
glob: ${{ inputs.glob }}
destination: ${{ steps.construct-path.outputs.destination }} # bucket name plus folder prefix (if applicable)
parent: ${{ inputs.parent }}
predefinedAcl: ${{ inputs.predefinedAcl }}
process_gcloudignore: false

0 comments on commit 97e6191

Please sign in to comment.