Skip to content

Commit 564e6a0

Browse files
authored
Add support for build_environment_variables (#210)
1 parent b15c729 commit 564e6a0

File tree

6 files changed

+34
-2
lines changed

6 files changed

+34
-2
lines changed

.github/workflows/integration.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ jobs:
220220
event_trigger_type: 'providers/cloud.pubsub/eventTypes/topic.publish'
221221
event_trigger_resource: '${{ secrets.DEPLOY_CF_EVENT_PUBSUB_TOPIC }}'
222222
env_vars_file: './tests/env-var-files/test.good.yaml'
223+
build_environment_variables: 'FOO=bar, ZIP=zap'
224+
build_environment_variables_file: './tests/env-var-files/test.good.yaml'
223225

224226
# Auth as the main account for integration and cleanup
225227
- uses: 'google-github-actions/auth@main'

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ steps:
9595

9696
- `deploy_timeout`: (Optional) The function deployment timeout in seconds. Defaults to 300.
9797

98+
- `build_environment_variables`: (Optional) List of environment variables that
99+
should be available while the function is built. Note this is different than
100+
runtime environment variables, which should be set with 'env_vars'.
101+
102+
- `build_environment_variables_file`: (Optional) Path to a local YAML file
103+
containing variables. See 'env_vars_file' for syntax.
104+
98105
- `credentials`: (**Deprecated**) This input is deprecated. See [auth section](https://github.com/google-github-actions/deploy-cloud-functions#via-google-github-actionsauth) for more details.
99106
Service account key to use for authentication. This should be
100107
the JSON formatted private key which can be exported from the Cloud Console. The

action.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,19 @@ inputs:
134134
default: 300
135135
required: false
136136

137+
build_environment_variables:
138+
description: |-
139+
Optional list of environment variables that should be available while the
140+
function is built. Note this is different than runtime environment
141+
variables, which should be set with 'env_vars'.
142+
required: false
143+
144+
build_environment_variables_file:
145+
description: |-
146+
Path to a local YAML file containing variables. See 'env_vars_file' for
147+
syntax.
148+
required: false
149+
137150
outputs:
138151
url:
139152
description: The URL of your Cloud Function. Only available with HTTP Trigger.

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ async function run(): Promise<void> {
6262
const deployTimeout = presence(getInput('deploy_timeout'));
6363
const labels = parseKVString(getInput('labels'));
6464

65+
const buildEnvVars = presence(getInput('build_environment_variables'));
66+
const buildEnvVarsFile = presence(
67+
getInput('build_environment_variables_file'),
68+
);
69+
6570
// Add warning if using credentials
6671
let credentialsJSON:
6772
| ServiceAccountKey
@@ -102,6 +107,10 @@ async function run(): Promise<void> {
102107
credentials: credentialsJSON,
103108
});
104109

110+
const buildEnvironmentVariables = parseKVStringAndFile(
111+
buildEnvVars,
112+
buildEnvVarsFile,
113+
);
105114
const environmentVariables = parseKVStringAndFile(envVars, envVarsFile);
106115

107116
// Create Function definition
@@ -110,7 +119,7 @@ async function run(): Promise<void> {
110119
runtime: runtime,
111120
description: description,
112121
availableMemoryMb: availableMemoryMb ? +availableMemoryMb : undefined,
113-
// buildEnvironmentVariables: buildEnvironmentVariables, // TODO: add support
122+
buildEnvironmentVariables: buildEnvironmentVariables,
114123
// buildWorkerPool: buildWorkerPool, // TODO: add support
115124
// dockerRepository: dockerRepository, // TODO: add support
116125
entryPoint: entryPoint,

tests/client.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ describe('CloudFunctionsClient', () => {
7474
name: testFunctionName,
7575
runtime: 'nodejs12',
7676
environmentVariables: { KEY1: 'VALUE1' },
77+
buildEnvironmentVariables: { KEY1: 'VALUE1' },
7778
entryPoint: 'helloWorld',
7879
availableMemoryMb: 512,
7980
sourceUploadUrl: sourceURL,

0 commit comments

Comments
 (0)