From e67211d38139a8f9d63db055b82a6bff93b2c5bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Ga=C5=82uszka?= Date: Sun, 24 Aug 2025 14:34:44 +0000 Subject: [PATCH 1/2] feat: add support for --wait flag in jobs --- action.yml | 7 +++++++ src/main.ts | 5 +++++ tests/unit/main.test.ts | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/action.yml b/action.yml index 6ef53868..3eadd49a 100644 --- a/action.yml +++ b/action.yml @@ -229,6 +229,13 @@ inputs: default: 'false' required: false + wait: + description: |- + If true, the action will wait for the job to complete before exiting. This + option only applies to jobs. + default: 'true' + required: false + revision_traffic: description: |- Comma-separated list of revision traffic assignments. diff --git a/src/main.ts b/src/main.ts index a18900c9..cd3b1caa 100644 --- a/src/main.ts +++ b/src/main.ts @@ -113,6 +113,7 @@ export async function run(): Promise { const tag = getInput('tag'); const timeout = getInput('timeout'); const noTraffic = (getInput('no_traffic') || '').toLowerCase() === 'true'; + const wait = parseBoolean(getInput('wait')); const revTraffic = getInput('revision_traffic'); const tagTraffic = getInput('tag_traffic'); const labels = parseKVString(getInput('labels')); @@ -196,6 +197,10 @@ export async function run(): Promise { setEnvVarsFlags(deployCmd, envVars, envVarsFile, envVarsUpdateStrategy); setSecretsFlags(deployCmd, secrets, secretsUpdateStrategy); + if (wait) { + deployCmd.push('--wait'); + } + // There is no --update-secrets flag on jobs, but there will be in the // future. At that point, we can remove this. const idx = deployCmd.indexOf('--update-secrets'); diff --git a/tests/unit/main.test.ts b/tests/unit/main.test.ts index 82f13dc2..882d43ee 100644 --- a/tests/unit/main.test.ts +++ b/tests/unit/main.test.ts @@ -520,6 +520,30 @@ test('#run', { concurrency: true }, async (suite) => { const args = mocks.getExecOutput.mock.calls?.at(0)?.arguments?.at(1); assertMembers(args, ['run', 'jobs', 'deploy', 'my-test-job']); }); + + await suite.test('deploys a job with --wait', async (t) => { + const mocks = defaultMocks(t.mock, { + job: 'my-test-job', + wait: 'true', + }); + + await run(); + + const args = mocks.getExecOutput.mock.calls?.at(0)?.arguments?.at(1); + assert.ok(args?.includes('--wait')); + }); + + await suite.test('deploys a job without --wait', async (t) => { + const mocks = defaultMocks(t.mock, { + job: 'my-test-job', + wait: 'false', + }); + + await run(); + + const args = mocks.getExecOutput.mock.calls?.at(0)?.arguments?.at(1); + assert.ok(!args.includes('--wait')); + }); }); const splitKV = (s: string): Record => { From 9392f06adc07d9241035e3104e892ac495dac371 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sun, 24 Aug 2025 16:59:05 -0400 Subject: [PATCH 2/2] Use a real job container --- .github/workflows/integration.yml | 11 +++++++---- .github/workflows/unit.yml | 1 + README.md | 8 ++++---- action.yml | 2 +- src/main.ts | 2 +- tests/fixtures/job.yaml | 2 +- tests/fixtures/service.yaml | 2 +- tests/unit/main.test.ts | 2 +- 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 0a1c560e..e1f2f8d7 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -26,13 +26,14 @@ defaults: jobs: deploy: runs-on: 'ubuntu-latest' + timeout-minutes: 7 strategy: fail-fast: false matrix: include: - name: 'image' - image: 'gcr.io/cloudrun/hello' + image: 'us-docker.pkg.dev/cloudrun/container/hello:latest' - name: 'source' source: 'example-app' @@ -153,6 +154,7 @@ jobs: metadata: runs-on: 'ubuntu-latest' + timeout-minutes: 7 steps: - uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4 @@ -206,7 +208,7 @@ jobs: name: 'Deploy again' uses: './' with: - image: 'gcr.io/cloudrun/hello' + image: 'us-docker.pkg.dev/cloudrun/container/hello:latest' service: '${{ env.SERVICE_NAME }}' revision_traffic: 'LATEST=100' @@ -229,6 +231,7 @@ jobs: jobs: runs-on: 'ubuntu-latest' + timeout-minutes: 7 steps: - uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4 @@ -252,7 +255,7 @@ jobs: name: 'Deploy' uses: './' with: - image: 'gcr.io/cloudrun/hello' + image: 'us-docker.pkg.dev/cloudrun/container/job:latest' job: '${{ env.JOB_NAME }}' env_vars: |- FOO=bar @@ -294,7 +297,7 @@ jobs: name: 'Deploy again' uses: './' with: - image: 'gcr.io/cloudrun/hello' + image: 'us-docker.pkg.dev/cloudrun/container/job:latest' job: '${{ env.JOB_NAME }}' env_vars: |- ABC=123 diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index b692dfd8..b9fba222 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -33,6 +33,7 @@ jobs: - 'windows-latest' - 'macos-latest' runs-on: '${{ matrix.os }}' + timeout-minutes: 7 steps: - uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4 diff --git a/README.md b/README.md index c50c1212..c241bd8d 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ jobs: uses: 'google-github-actions/deploy-cloudrun@v2' with: service: 'hello-cloud-run' - image: 'gcr.io/cloudrun/hello' + image: 'us-docker.pkg.dev/cloudrun/container/hello:latest' - name: 'Use output' run: 'curl "${{ steps.deploy.outputs.url }}"' @@ -67,7 +67,7 @@ jobs: - image: _(Optional)_ (Required, unless providing `metadata` or `source`) Fully-qualified name of the container image to deploy. For example: - gcr.io/cloudrun/hello:latest + us-docker.pkg.dev/cloudrun/container/hello:latest or @@ -362,7 +362,7 @@ jobs: - uses: 'google-github-actions/deploy-cloudrun@v2' with: - image: 'gcr.io/cloudrun/hello' + image: 'us-docker.pkg.dev/cloudrun/container/hello:latest' service: 'hello-cloud-run' ``` @@ -381,7 +381,7 @@ jobs: - uses: 'google-github-actions/deploy-cloudrun@v2' with: - image: 'gcr.io/cloudrun/hello' + image: 'us-docker.pkg.dev/cloudrun/container/hello:latest' service: 'hello-cloud-run' ``` diff --git a/action.yml b/action.yml index 3eadd49a..b0677a1d 100644 --- a/action.yml +++ b/action.yml @@ -41,7 +41,7 @@ inputs: (Required, unless providing `metadata` or `source`) Fully-qualified name of the container image to deploy. For example: - gcr.io/cloudrun/hello:latest + us-docker.pkg.dev/cloudrun/container/hello:latest or diff --git a/src/main.ts b/src/main.ts index cd3b1caa..52fc3ec7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -95,7 +95,7 @@ export async function run(): Promise { try { // Get action inputs - const image = getInput('image'); // Image ie gcr.io/... + const image = getInput('image'); // Image ie us-docker.pkg.dev/... let service = getInput('service'); // Service name const job = getInput('job'); // Job name const metadata = getInput('metadata'); // YAML file diff --git a/tests/fixtures/job.yaml b/tests/fixtures/job.yaml index b54da4cb..69315931 100644 --- a/tests/fixtures/job.yaml +++ b/tests/fixtures/job.yaml @@ -15,7 +15,7 @@ spec: template: spec: containers: - - image: 'gcr.io/cloudrun/hello' + - image: 'us-docker.pkg.dev/cloudrun/container/job:latest' imagePullPolicy: 'Always' resources: limits: diff --git a/tests/fixtures/service.yaml b/tests/fixtures/service.yaml index 2f6aaeac..26695b1a 100644 --- a/tests/fixtures/service.yaml +++ b/tests/fixtures/service.yaml @@ -12,7 +12,7 @@ spec: spec: containerConcurrency: 20 containers: - - image: 'gcr.io/cloudrun/hello' + - image: 'us-docker.pkg.dev/cloudrun/container/hello:latest' ports: - containerPort: 8080 resources: diff --git a/tests/unit/main.test.ts b/tests/unit/main.test.ts index 882d43ee..912328cb 100644 --- a/tests/unit/main.test.ts +++ b/tests/unit/main.test.ts @@ -27,7 +27,7 @@ import { assertMembers } from '@google-github-actions/actions-utils'; import { run } from '../../src/main'; const fakeInputs: { [key: string]: string } = { - image: 'gcr.io/cloudrun/hello', + image: 'us-docker.pkg.dev/cloudrun/container/hello:latest', project_id: 'test', };