google-github-actions/deploy-cloudrun@v3

Use this action to deploy a container or source code to Google Cloud Run.

At a glance

Latest major
v3
Repository
google-github-actions/deploy-cloudrun
Inputs
24 (2 required)
Outputs
1
Runs using
node24
License
Apache-2.0
Last checked

Inputs and outputs come straight from the action's official action.yml. See our editorial standards.

Usage

- uses: google-github-actions/deploy-cloudrun@v3

Inputs

NameRequiredDefaultDescription
serviceNononeID of the service or fully-qualified identifier of the service. This is required unless providing `metadata` or `job`.
jobNononeID of the job or fully-qualified identifier of the job. This is required unless providing `metadata` or `service`.
metadataNononeYAML service description for the Cloud Run service. This is required unless providing `service` or `job`.
imageNonone(Required, unless providing `metadata` or `source`) Fully-qualified name of the container image to deploy. For example: us-docker.pkg.dev/cloudrun/container/hello:latest or us-docker.pkg.dev/my-project/my-container/image:1.2.3
sourceNonone(Required, unless providing `metadata`, `image`, or `job`) Path to source to deploy. If specified, this will deploy the Cloud Run service from the code specified at the given source directory. Learn more about the required permissions in [Deploying from source code](https://cloud.google.com/run/docs/deploying-source-code).
suffixNononeString suffix to append to the revision name. Revision names always start with the service name automatically. For example, specifying `v1` for a service named `helloworld`, would lead to a revision named `helloworld-v1`. This option only applies to services.
env_varsNononeList of environment variables that should be set in the environment. These are comma-separated or newline-separated `KEY=VALUE`. Keys or values that contain separators must be escaped with a backslash (e.g. `\,` or `\\n`) unless quoted. Any leading or trailing whitespace is trimmed unless values are quoted. ```yaml env_vars: |- FRUIT=apple SENTENCE=" this will retain leading and trailing spaces " ``` This value will only be set if the input is a non-empty value. If a non-empty value is given, the field values will be overwritten (not merged). To remove all values, set the value to the literal string `{}`. If both `env_vars` and `env_vars_file` are specified, the keys in `env_vars` will take
env_vars_update_strategyYesmergeControls how the environment variables are set on the Cloud Run service. If set to "merge", then the environment variables are _merged_ with any upstream values. If set to "overwrite", then all environment variables on the Cloud Run service will be replaced with exactly the values given by the GitHub Action (making it authoritative).
secretsNononeList of KEY=VALUE pairs to use as secrets. These are comma-separated or newline-separated `KEY=VALUE`. Keys or values that contain separators must be escaped with a backslash (e.g. `\,` or `\\n`) unless quoted. Any leading or trailing whitespace is trimmed unless values are quoted. These can either be injected as environment variables or mounted as volumes. Keys starting with a forward slash '/' are mount paths. All other keys correspond to environment variables: ```yaml with: secrets: |- # As an environment variable: KEY1=secret-key-1:latest # As a volume mount: /secrets/api/key=secret-key-2:latest ``` This value will only be set if the input is a non-empty value. If a non-empty value is gi
secrets_update_strategyYesmergeControls how the secrets are set on the Cloud Run service. If set to `merge`, then the secrets are merged with any upstream values. If set to `overwrite`, then all secrets on the Cloud Run service will be replaced with exactly the values given by the GitHub Action (making it authoritative).
labelsNononeList of labels that should be set on the function. These are comma-separated or newline-separated `KEY=VALUE`. Keys or values that contain separators must be escaped with a backslash (e.g. `\,` or `\\n`) unless quoted. Any leading or trailing whitespace is trimmed unless values are quoted. ```yaml labels: |- labela=my-label labelb=my-other-label ``` This value will only be set if the input is a non-empty value. If a non-empty value is given, the field values will be overwritten (not merged). To remove all values, set the value to the literal string `{}`. Google Cloud restricts the allowed values and length for labels. Please see the Google Cloud documentation for labels for more information.
skip_default_labelsNofalseSkip applying the special annotation labels that indicate the deployment came from GitHub Actions. The GitHub Action will automatically apply the following labels which Cloud Run uses to enhance the user experience: managed-by: github-actions commit-sha: <sha> Setting this to `true` will skip adding these special labels.
tagNononeTraffic tag to assign to the newly-created revision. This option only applies to services.
timeoutNononeMaximum request execution time, specified as a duration like "10m5s" for ten minutes and 5 seconds.
flagsNononeSpace separate list of additional Cloud Run flags to pass to the deploy command. This can be used to apply advanced features that are not exposed via this GitHub Action. For Cloud Run services, this command will be `gcloud run deploy`. For Cloud Run jobs, this command will be `gcloud jobs deploy`. ```yaml with: flags: '--add-cloudsql-instances=...' ``` Flags that include other flags must quote the _entire_ outer flag value. For example, to pass `--args=-X=123`: ```yaml with: flags: '--add-cloudsql-instances=... "--args=-X=123"' ``` See the [complete list of flags](https://cloud.google.com/sdk/gcloud/reference/run/deploy#FLAGS) for more information. Please note, this GitHub Action does not pa
no_trafficNofalseIf true, the newly deployed revision will not receive traffic. This option only applies to services.
waitNofalseIf true, the action will execute and wait for the job to complete before exiting. This option only applies to jobs.
revision_trafficNononeComma-separated list of revision traffic assignments. ```yaml with: revision_traffic: 'my-revision=10' # percentage ``` To update traffic to the latest revision, use the special tag "LATEST": ```yaml with: revision_traffic: 'LATEST=100' ``` This is mutually-exclusive with `tag_traffic`. This option only applies to services.
tag_trafficNononeComma-separated list of tag traffic assignments. ```yaml with: tag_traffic: 'my-tag=10' # percentage ``` This is mutually-exclusive with `revision_traffic`. This option only applies to services.
update_traffic_flagsNononeSpace separate list of additional Cloud Run flags to pass to the `gcloud run services update-traffic` command. This can be used to apply advanced features that are not exposed via this GitHub Action. This flag only applies when `revision_traffic` or `tag_traffic` is set. ```yaml with: traffic_flags: '--set-tags=...' ``` Flags that include other flags must quote the _entire_ outer flag value. For example, to pass `--args=-X=123`: ```yaml with: flags: '--set-tags=... "--args=-X=123"' ``` See the [complete list of flags](https://cloud.google.com/sdk/gcloud/reference/run/services/update#FLAGS) for more information. Please note, this GitHub Action does not parse or validate the flags. You are res
project_idNononeID of the Google Cloud project in which to deploy the service.
regionNous-central1Region in which the Cloud Run services are deployed.
gcloud_versionNononeVersion of the Cloud SDK to install. If unspecified or set to "latest", the latest available gcloud SDK version for the target platform will be installed. Example: "290.0.1".
gcloud_componentNononeVersion of the Cloud SDK components to install and use.

Outputs

NameDescription
urlThe URL of the Cloud Run service.

Read an output with ${{ steps.<step-id>.outputs.<name> }}; the step needs an id.

Examples

Deploy an image to Cloud Run

Update a service to a container image you already pushed.

name: Example
on:
  push:
    branches: [main]

permissions:
  contents: read
  id-token: write

jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - uses: google-github-actions/auth@v3
        with:
          workload_identity_provider: projects/123456789/locations/global/workloadIdentityPools/github/providers/my-repo
          service_account: [email protected]
      - name: Deploy to Cloud Run
        id: deploy
        uses: google-github-actions/deploy-cloudrun@v3
        with:
          service: my-service
          image: "us-docker.pkg.dev/my-project/my-repo/my-app:latest"
          region: us-central1
      - name: Use the output
        run: echo "url = ${{ steps.deploy.outputs.url }}"

Each example passed actionlint (syntax, expressions and the inputs it knows for this action). They were not run in a live repository, so replace placeholder values such as names, ARNs and paths with your own.

Something out of date or wrong? Report it on our Contact page. This page is rebuilt from the action's repository roughly once a week.