Skip to content

Commit ccce605

Browse files
committed
Add support for Cloud Run jobs
1 parent aafe258 commit ccce605

File tree

9 files changed

+2879
-179
lines changed

9 files changed

+2879
-179
lines changed

.github/workflows/integration.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,104 @@ jobs:
225225
"run.googleapis.com/cloudsql-instances": "test-project:us-central1:my-test-instance"
226226
}
227227
REVISION_COUNT: 2
228+
229+
jobs:
230+
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name && github.actor != 'dependabot[bot]' }}
231+
runs-on: 'ubuntu-latest'
232+
233+
steps:
234+
- uses: 'actions/checkout@v4'
235+
236+
- name: 'Compute job name'
237+
run: |-
238+
echo "JOB_NAME=${GITHUB_JOB}-job-${GITHUB_SHA::7}-${GITHUB_RUN_NUMBER}" >> ${GITHUB_ENV}
239+
240+
- uses: 'actions/setup-node@v4'
241+
with:
242+
node-version: '20.x'
243+
244+
- run: 'npm ci && npm run build'
245+
246+
- uses: 'google-github-actions/auth@v2'
247+
with:
248+
workload_identity_provider: '${{ vars.WIF_PROVIDER_NAME }}'
249+
service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
250+
251+
- id: 'deploy-cloudrun'
252+
name: 'Deploy'
253+
uses: './'
254+
with:
255+
image: 'gcr.io/cloudrun/hello'
256+
job: '${{ env.JOB_NAME }}'
257+
env_vars: |-
258+
FOO=bar
259+
ZIP=zap\,with|separators\,and&stuff
260+
env_vars_file: './tests/fixtures/env_vars.txt'
261+
secrets: |-
262+
MY_SECRET=${{ vars.SECRET_NAME }}:latest
263+
MY_SECOND_SECRET=${{ vars.SECRET_NAME }}:1
264+
labels: |-
265+
label1=value1
266+
label2=value2
267+
skip_default_labels: true
268+
flags: '--cpu=2'
269+
270+
- name: 'Run initial deploy tests'
271+
run: 'npm run e2e-tests'
272+
env:
273+
PROJECT_ID: ${{ vars.PROJECT_ID }}
274+
JOB: '${{ env.JOB_NAME }}'
275+
ENV: |-
276+
{
277+
"FOO": "bar",
278+
"ZIP": "zap,with|separators,and&stuff",
279+
"TEXT_FOO": "bar",
280+
"TEXT_ZIP": "zap,with|separators,and&stuff"
281+
}
282+
SECRET_ENV: |-
283+
{
284+
"MY_SECRET": "${{ vars.SECRET_NAME }}:latest",
285+
"MY_SECOND_SECRET": "${{ vars.SECRET_NAME }}:1"
286+
}
287+
LABELS: |-
288+
{
289+
"label1": "value1",
290+
"label2": "value2"
291+
}
292+
293+
- id: 'deploy-cloudrun-again'
294+
name: 'Deploy again'
295+
uses: './'
296+
with:
297+
image: 'gcr.io/cloudrun/hello'
298+
job: '${{ env.JOB_NAME }}'
299+
env_vars: |-
300+
ABC=123
301+
DEF=456
302+
secrets: /api/secrets/my-secret=${{ vars.SECRET_NAME }}:latest
303+
304+
- name: 'Run re-deploy tests'
305+
run: 'npm run e2e-tests'
306+
env:
307+
PROJECT_ID: ${{ vars.PROJECT_ID }}
308+
JOB: '${{ env.JOB_NAME }}'
309+
ENV: |-
310+
{
311+
"FOO": "bar",
312+
"ZIP": "zap,with|separators,and&stuff",
313+
"TEXT_FOO": "bar",
314+
"TEXT_ZIP": "zap,with|separators,and&stuff",
315+
"ABC": "123",
316+
"DEF": "456"
317+
}
318+
SECRET_VOLUMES: |-
319+
{
320+
"/api/secrets/my-secret": "${{ vars.SECRET_NAME }}:latest"
321+
}
322+
LABELS: |-
323+
{
324+
"label1": "value1",
325+
"label2": "value2",
326+
"commit-sha": "${{ github.sha }}",
327+
"managed-by": "github-actions"
328+
}

README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,14 @@ jobs:
5353
5454
## Inputs
5555
56-
- `service`: (Required, unless providing `metadata`) ID of the service or
57-
fully-qualified identifier of the service.
56+
- `service`: (Required, unless providing `metadata` or `job`) ID of the
57+
service or fully-qualified identifier of the service.
5858

59-
- `job`: (Required, unless providing `metadata`, `service`, or `image`) ID of
60-
the job or fully-qualified identifier of the job. If `job` and `service` are
61-
specified then the `service` will be updated and the `job` will be ignored.
62-
Note that the `job` must be created first. This will only update an existing
63-
`job`, it will not deploy/create a new job.
59+
- `job`: (Required, unless providing `metadata` or `service`) ID of
60+
the job or fully-qualified identifier of the job.
6461

65-
- `image`: (Required, unless providing `metadata`, `source`, or `job`)
66-
Fully-qualified name of the container image to deploy. For example:
62+
- `image`: (Required, unless providing `metadata` or `source`) Fully-qualified
63+
name of the container image to deploy. For example:
6764

6865
```text
6966
gcr.io/cloudrun/hello:latest

action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ description: |-
2020
inputs:
2121
service:
2222
description: |-
23-
(Required, unless providing `metadata`) ID of the service or
23+
(Required, unless providing `metadata` or `job`) ID of the service or
2424
fully-qualified identifier of the service.
2525
required: false
2626

2727
image:
2828
description: |-
29-
(Required, unless providing `metadata`, `source`, or `job`)
30-
Fully-qualified name of the container image to deploy. For example:
29+
(Required, unless providing `metadata` or `source`) Fully-qualified name
30+
of the container image to deploy. For example:
3131
3232
gcr.io/cloudrun/hello:latest
3333
@@ -50,8 +50,8 @@ inputs:
5050

5151
job:
5252
description: |-
53-
(Required, unless providing `metadata`, `service`, or `image`) ID of the
54-
job or fully-qualified identifier of the job. If `job` and `service` are
53+
(Required, unless providing `metadata` or `service`) ID of the job or
54+
fully-qualified identifier of the job. If `job` and `service` are
5555
specified then the `service` will be updated and the `job` will be
5656
ignored. Note that the `job` must be created first. This will only update
5757
an existing `job`, it will not deploy/create a new job.

dist/main/index.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)