Skip to content

Commit e67211d

Browse files
committed
feat: add support for --wait flag in jobs
1 parent 1477328 commit e67211d

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@ inputs:
229229
default: 'false'
230230
required: false
231231

232+
wait:
233+
description: |-
234+
If true, the action will wait for the job to complete before exiting. This
235+
option only applies to jobs.
236+
default: 'true'
237+
required: false
238+
232239
revision_traffic:
233240
description: |-
234241
Comma-separated list of revision traffic assignments.

src/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export async function run(): Promise<void> {
113113
const tag = getInput('tag');
114114
const timeout = getInput('timeout');
115115
const noTraffic = (getInput('no_traffic') || '').toLowerCase() === 'true';
116+
const wait = parseBoolean(getInput('wait'));
116117
const revTraffic = getInput('revision_traffic');
117118
const tagTraffic = getInput('tag_traffic');
118119
const labels = parseKVString(getInput('labels'));
@@ -196,6 +197,10 @@ export async function run(): Promise<void> {
196197
setEnvVarsFlags(deployCmd, envVars, envVarsFile, envVarsUpdateStrategy);
197198
setSecretsFlags(deployCmd, secrets, secretsUpdateStrategy);
198199

200+
if (wait) {
201+
deployCmd.push('--wait');
202+
}
203+
199204
// There is no --update-secrets flag on jobs, but there will be in the
200205
// future. At that point, we can remove this.
201206
const idx = deployCmd.indexOf('--update-secrets');

tests/unit/main.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,30 @@ test('#run', { concurrency: true }, async (suite) => {
520520
const args = mocks.getExecOutput.mock.calls?.at(0)?.arguments?.at(1);
521521
assertMembers(args, ['run', 'jobs', 'deploy', 'my-test-job']);
522522
});
523+
524+
await suite.test('deploys a job with --wait', async (t) => {
525+
const mocks = defaultMocks(t.mock, {
526+
job: 'my-test-job',
527+
wait: 'true',
528+
});
529+
530+
await run();
531+
532+
const args = mocks.getExecOutput.mock.calls?.at(0)?.arguments?.at(1);
533+
assert.ok(args?.includes('--wait'));
534+
});
535+
536+
await suite.test('deploys a job without --wait', async (t) => {
537+
const mocks = defaultMocks(t.mock, {
538+
job: 'my-test-job',
539+
wait: 'false',
540+
});
541+
542+
await run();
543+
544+
const args = mocks.getExecOutput.mock.calls?.at(0)?.arguments?.at(1);
545+
assert.ok(!args.includes('--wait'));
546+
});
523547
});
524548

525549
const splitKV = (s: string): Record<string, string> => {

0 commit comments

Comments
 (0)