Skip to content

Commit 5cab4a9

Browse files
feat: allow for multi line secrets (#224)
* feat: allow for multi line secrets * split on new line * Update readme * Fix test * debug * fix test * fix Co-authored-by: Bharath KKB <[email protected]>
1 parent 50aa77a commit 5cab4a9

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

.github/workflows/deploy-cloudrun-it.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ jobs:
8787
credentials: ${{ secrets.DEPLOY_CLOUDRUN_SA_KEY_JSON }}
8888
image: gcr.io/cloudrun/hello
8989
service: ${{ steps.service.outputs.service }}
90-
secrets: MY_SECRET=secret_value:latest
90+
secrets: |
91+
MY_SECRET=secret_value:latest
92+
MY_SECOND_SECRET=new_value:latest
9193
9294
- name: Setup Authentication with gcloud
9395
uses: google-github-actions/setup-gcloud@master
@@ -101,7 +103,7 @@ jobs:
101103
URL: ${{ steps.deploy_1.outputs.url }}
102104
PROJECT_ID: ${{ secrets.DEPLOY_CLOUDRUN_PROJECT_ID }}
103105
SERVICE: ${{ steps.service.outputs.service }}
104-
SECRET_ENV: MY_SECRET=secret_value:latest
106+
SECRET_ENV: MY_SECRET=secret_value:latest,MY_SECOND_SECRET=new_value:latest
105107

106108
- name: Update service with mounted secret
107109
id: deploy_2
@@ -118,7 +120,7 @@ jobs:
118120
URL: ${{ steps.deploy_2.outputs.url }}
119121
PROJECT_ID: ${{ secrets.DEPLOY_CLOUDRUN_PROJECT_ID }}
120122
SERVICE: ${{ steps.service.outputs.service }}
121-
SECRET_ENV: MY_SECRET=secret_value:latest
123+
SECRET_ENV: MY_SECRET=secret_value:latest,MY_SECOND_SECRET=new_value:latest
122124
SECRET_VOLUMES: /api/secrets/my-secret=secret_value:latest
123125
COUNT: 2
124126

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
| `image`| Required if not using a service YAML via `metadata` input. | | Name of the container image to deploy (Example: `gcr.io/cloudrun/hello:latest`). |
7878
| `region`| _optional_ | `us-central1` | Region in which the resource can be found. |
7979
| `env_vars`| _optional_ | | List of key-value pairs to set as environment variables in the format: `KEY1=VALUE1,KEY2=VALUE2`. **All existing environment variables will be retained**. |
80-
| `secrets`| _optional_ | | List of key-value pairs to set as either environment variables or mounted volumes in the format: `KEY1=secret-key-1:latest,/secrets/api/key=secret-key-2:latest`. The secrets will be fetched from the Secret Manager. **All existing environment secrets or volumes will be retained**. |
80+
| `secrets`| _optional_ | | List of key-value pairs to set as either environment variables or mounted volumes in the format: `KEY1=secret-key-1:latest,/secrets/api/key=secret-key-2:latest`. The secrets will be fetched from the Secret Manager. The service identity must have permissions to read the secrets. Multiple secrets can be split across multiple lines: <pre>secrets: \|<br>&emsp;&emsp;SECRET_NAME=secret_name<br>&emsp;&emsp;SECRET_NAME2=secret_name2</pre> <br>**All existing environment secrets or volumes will be retained**. |
8181
| `metadata`| _optional_ | | YAML service description for the Cloud Run service (**Other inputs will be overridden**). See [Metadata customizations](#metadata-customizations) for more information. |
8282
| `project_id`| _optional_ | | ID of the Google Cloud project. If provided, this will override the project configured by `setup-gcloud`. |
8383
| `source` | _optional_ | | Deploy from source by specifying the source directory. The [Artifact Registry API][artifact-api] needs to be enabled and the service account role `Cloud Build Service Account` is required. The first deployment will create an [Artifact Registry repository][repo] which requires the `Artifact Registry Admin` role. Learn more about [Deploying from source code](https://cloud.google.com/run/docs/deploying-source-code). |

src/deploy-cloudrun.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export async function run(): Promise<void> {
149149
// Set optional flags from inputs
150150
if (envVars) cmd.push('--update-env-vars', envVars);
151151
if (secrets) {
152-
cmd.push('--update-secrets', secrets);
152+
cmd.push('--update-secrets', secrets.replace('\n', ','));
153153
installBeta = true;
154154
}
155155
if (tag) {

0 commit comments

Comments
 (0)