Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -153,6 +154,7 @@ jobs:

metadata:
runs-on: 'ubuntu-latest'
timeout-minutes: 7

steps:
- uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4
Expand Down Expand Up @@ -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'

Expand All @@ -229,6 +231,7 @@ jobs:

jobs:
runs-on: 'ubuntu-latest'
timeout-minutes: 7

steps:
- uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"'
Expand All @@ -67,7 +67,7 @@ jobs:
- <a name="image"></a><a href="#user-content-image"><code>image</code></a>: _(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

Expand Down Expand Up @@ -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'
```

Expand All @@ -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'
```

Expand Down
9 changes: 8 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export async function run(): Promise<void> {

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
Expand All @@ -113,6 +113,7 @@ export async function run(): Promise<void> {
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'));
Expand Down Expand Up @@ -196,6 +197,10 @@ export async function run(): Promise<void> {
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');
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
26 changes: 25 additions & 1 deletion tests/unit/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};

Expand Down Expand Up @@ -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<string, string> => {
Expand Down
Loading