Skip to content

Commit dca39b7

Browse files
authored
Add support for deploy parameters feature (#42)
This PR adds support for the [deploy parameters](https://cloud.google.com/deploy/docs/parameters) feature, now GA in Cloud Deploy.
1 parent bdf0e39 commit dca39b7

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,19 @@ jobs:
132132

133133
- `description`: (Optional) Include a description of the release.
134134

135+
- `deploy_parameters`: (Optional) Additional parameters to supply at release creation time.
136+
137+
```yaml
138+
with:
139+
deploy_parameters: |-
140+
parameter1=value1
141+
parameter2=value2
142+
```
143+
144+
See the [Deploy Parameters](https://cloud.google.com/deploy/docs/parameters)
145+
section in the Cloud Deploy documentation for details of how to use the corresponding
146+
placeholders in your manifest(s).
147+
135148
- `flags`: (Optional) Space separated list of other Cloud Deploy flags,
136149
examples can be found [here][cd-flags]. This can be used to access features
137150
that are not exposed via this GitHub Action.

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ inputs:
7979
Include a description of the release.
8080
required: false
8181

82+
deploy_parameters:
83+
description: |-
84+
Additional parameters to supply at release creation time.
85+
required: false
86+
8287
flags:
8388
description: |-
8489
Space separated list of other Cloud Deploy flags, examples can be found:

src/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export async function run(): Promise<void> {
8787
const annotations = parseKVString(getInput('annotations'));
8888
const labels = parseKVString(getInput('labels'));
8989
const description = getInput('description');
90+
const deployParameters = parseKVString(getInput('deploy_parameters'));
9091
const flags = getInput('flags');
9192
const gcloudComponent = presence(getInput('gcloud_component'));
9293
const gcloudVersion = getInput('gcloud_version');
@@ -140,6 +141,9 @@ export async function run(): Promise<void> {
140141
if (skaffoldFile) {
141142
cmd.push('--skaffold-file', skaffoldFile);
142143
}
144+
if (deployParameters) {
145+
cmd.push('--deploy-parameters', joinKVString(deployParameters));
146+
}
143147

144148
const allAnnotations = Object.assign({}, getDefaultAnnotations(), annotations);
145149
cmd.push('--annotations', joinKVString(allAnnotations));

tests/unit/main.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const fakeInputs: { [key: string]: string } = {
3939
sourceStagingDir: '',
4040
skaffoldFile: '',
4141
description: '',
42+
deploy_parameters: '',
4243
flags: '',
4344
annotations: '',
4445
labels: '',
@@ -266,6 +267,20 @@ describe('#run', function () {
266267
expect(args).to.include.members(['--description', 'My description']);
267268
});
268269

270+
it('sets deploy parameters if given', async function () {
271+
this.stubs.getInput.withArgs('deploy_parameters').returns('param-key=param-value');
272+
273+
const expectedParameters = {
274+
'param-key': 'param-value',
275+
};
276+
277+
await run();
278+
const call = this.stubs.getExecOutput.getCall(0);
279+
expect(call).to.be;
280+
const args = call.args[1];
281+
expect(args).to.include.members(['--deploy-parameters', joinKVString(expectedParameters)]);
282+
});
283+
269284
it('sets flags if given', async function () {
270285
this.stubs.getInput.withArgs('flags').returns('--flag1=value1 --flag2=value2');
271286
await run();

0 commit comments

Comments
 (0)