All Projects → google-github-actions → deploy-cloudrun

google-github-actions / deploy-cloudrun

Licence: Apache-2.0 license
This action deploys your container image to Cloud Run.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to deploy-cloudrun

auth
A GitHub Action for authenticating to Google Cloud.
Stars: ✭ 567 (+138.24%)
Mutual labels:  actions, gcp, google-cloud, google-cloud-platform
deploy-appengine
A GitHub Action that deploys source code to Google App Engine.
Stars: ✭ 184 (-22.69%)
Mutual labels:  actions, gcp, google-cloud, google-cloud-platform
All About Programming
Everything about programming!!
Stars: ✭ 314 (+31.93%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
Cloud Functions Go
Unofficial Native Go Runtime for Google Cloud Functions
Stars: ✭ 427 (+79.41%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
Unity Solutions
Use Firebase tools to incorporate common features into your games!
Stars: ✭ 95 (-60.08%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
laravel6-on-google-cloud-run
Laravel 6 on Google cloud run for a demo
Stars: ✭ 25 (-89.5%)
Mutual labels:  google-cloud, google-cloud-run, cloud-run
restme
Template to bootstrap a fully functional, multi-region, REST service on GCP with a developer release pipeline.
Stars: ✭ 19 (-92.02%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
Fog Google
Fog for Google Cloud Platform
Stars: ✭ 83 (-65.13%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
iris3
An upgraded and improved version of the Iris automatic GCP-labeling project
Stars: ✭ 38 (-84.03%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
cloudrun-tutorial
A tutorial showing some of the features of Cloud Run
Stars: ✭ 79 (-66.81%)
Mutual labels:  google-cloud, google-cloud-run, cloud-run
Googlecloudarchitectprofessional
Resources to prepare for Google Certified Cloud Architect Professional Exam - 2017
Stars: ✭ 177 (-25.63%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
awesome-bigquery-views
Useful SQL queries for Blockchain ETL datasets in BigQuery.
Stars: ✭ 325 (+36.55%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
Google-Cloud-Study-Jams
Resources for 30 Days of Google Cloud program workshops and events conducted by GDSC VJTI
Stars: ✭ 13 (-94.54%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
argon
Campaign Manager 360 and Display & Video 360 Reports to BigQuery connector
Stars: ✭ 31 (-86.97%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
rowy
Open-source Airtable-like experience for your database (Firestore) with GCP's scalability. Build any automation or cloud functions for your product. ⚡️✨
Stars: ✭ 2,676 (+1024.37%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
Cloud-Service-Providers-Free-Tier-Overview
Comparing the free tier offers of the major cloud providers like AWS, Azure, GCP, Oracle etc.
Stars: ✭ 226 (-5.04%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
Grpc Gke Nlb Tutorial
gRPC load-balancing on GKE using Envoy
Stars: ✭ 42 (-82.35%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
GoogleCloudLogging
Swift (Darwin) library for logging application events in Google Cloud.
Stars: ✭ 24 (-89.92%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
zorya
Google Cloud Instance Scheduler helping to reduce costs by 60% on average for non-production environments.
Stars: ✭ 127 (-46.64%)
Mutual labels:  gcp, google-cloud, google-cloud-platform
Gcpsketchnote
If you are looking to become a Google Cloud Engineer , then you are at the right place. GCPSketchnote is series where I share Google Cloud concepts in quick and easy to learn format.
Stars: ✭ 2,631 (+1005.46%)
Mutual labels:  gcp, google-cloud, google-cloud-platform

deploy-cloudrun

The deploy-cloudrun GitHub Action deploys to Google Cloud Run. It can deploy a container image or from source, and the resulting service URL is available as a GitHub Actions output for use in future steps.

Prerequisites

  • For authenticating to Google Cloud, you must create a Workload Identity Provider or export credentials. See Credentials for more information.

  • For deploying from source, you must run the actions/checkout@v3 step before this action.

  • You must enable the Cloud Run API.

  • This action runs using Node 16. If you are using self-hosted GitHub Actions runners, you must use runner version 2.285.0 or newer.

Usage

jobs:
  job_id:
    # ...

    permissions:
      contents: 'read'
      id-token: 'write'

    steps:
    - id: 'auth'
      uses: 'google-github-actions/auth@v0'
      with:
        workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
        service_account: '[email protected]'

    - id: 'deploy'
      uses: 'google-github-actions/deploy-cloudrun@v0'
      with:
        service: 'hello-cloud-run'
        image: 'gcr.io/cloudrun/hello'

    - name: 'Use output'
      run: 'curl "${{ steps.deploy.outputs.url }}"'

Inputs

  • service: (Required, unless providing metadata) ID of the service or fully-qualified identifier of the service.

  • image: (Required, unless providing metadata or source) Fully-qualified name of the container image to deploy. For example:

    gcr.io/cloudrun/hello:latest
    

    or

    us-docker.pkg.dev/my-project/my-container/image:1.2.3
    
  • source: (Required, unless providing metadata or image) Path to source to deploy. If specified, this will deploy the Cloud Run service from the code specified at the given source directory.

    This requires the Artifact Registry API to be enabled. Furthermore, the deploying service account must have the Cloud Build Service Account role. The initial deployment will create an Artifact Registry repository which requires the Artifact Registry Admin role.

    Learn more about Deploying from source code.

  • suffix: (Optional) String suffix to append to the revision name. The default value is no suffix.

  • env_vars: (Optional) List of key=value pairs to set as environment variables. All existing environment variables will be retained.

    with:
      env_vars: |
        FOO=bar
        ZIP=zap
  • secrets: (Optional) List of key=value pairs to use as secrets. These can either be injected as environment variables or mounted as volumes. All existing environment secrets and volume mounts will be retained.

    with:
      secrets: |
        # As an environment variable:
        KEY1=secret-key-1:latest
    
        # As a volume mount:
        /secrets/api/key=secret-key-2:latest
  • labels: (Optional) List of key=value pairs to set as labels on the Cloud Run service. Existing labels will be overwritten.

    with:
      labels:
        my-label=my-value

    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>
    

    Labels have strict naming and casing requirements. See Requirements for labels for more information.

  • tag: (Optional) Traffic tag to assign to the newly-created revision.

  • timeout: (Optional) Maximum request execution time, specified as a duration like "10m5s" for ten minutes and 5 seconds.

  • flags: (Optional) Space separate list of other Cloud Run flags. This can be used to access features that are not exposed via this GitHub Action.

    with:
      flags: '--add-cloudsql-instances=...'

    See the complete list of flags for more information.

  • no_traffic: (Optional) If true, the newly deployed revision will not receive traffic. The default value is false.

  • revision_traffic: (Optional, mutually-exclusive with tag_traffic) Comma-separated list of revision traffic assignments.

    with:
      revision_traffic: 'my-revision=10' # percentage
  • tag_traffic: (Optional, mutually-exclusive with revision_traffic) Comma-separated list of tag traffic assignments.

    with:
      tag_traffix: 'my-tag=10' # percentage
  • project_id: (Optional) ID of the Google Cloud project in which to deploy the service. The default value is computed from the environment.

  • region: (Optional) Region in which to deploy the service. The default value is us-central1.

  • gcloud_version: (Optional) Version of the gcloud CLI to use. The default value is latest.

  • gcloud_component: (Optional) Component of the gcloud CLI to use. Valid values are alpha and beta.

Custom metadata YAML

For advanced use cases, you can define a custom Cloud Run metadata file. This is a YAML description of the Cloud Run service. This allows you to customize your service configuration, such as memory limits, CPU allocation, max instances, and more.

⚠️ When using a custom metadata YAML file, all other inputs are ignored!

  • metadata: (Optional) The path to a Cloud Run service metadata file.

To deploying a new service to create a new YAML service definition:

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: SERVICE
spec:
  template:
    spec:
      containers:
      - image: IMAGE

To update a revision or to deploy a new revision of an existing service, download and modify the YAML service definition:

gcloud run services describe SERVICE --format yaml > service.yaml

Allowing unauthenticated requests

A Cloud Run product recommendation is that CI/CD systems not set or change settings for allowing unauthenticated invocations. New deployments are automatically private services, while deploying a revision of a public (unauthenticated) service will preserve the IAM setting of public (unauthenticated). For more information, see Controlling access on an individual service.

Outputs

  • url: The URL of your Cloud Run service.

Credentials

Via google-github-actions/auth

Use google-github-actions/auth to authenticate the action. This Action supports both the recommended Workload Identity Federation based authentication and the traditional Service Account Key JSON based auth.

See usage for more details.

A service account will be needed with the following roles:

  • Cloud Run Admin (roles/run.admin):
    • Can create, update, and delete services.
    • Can get and set IAM policies.

This service account needs to be a member of the Compute Engine default service account, ([email protected]), with role Service Account User. To grant a user permissions for a service account, use one of the methods found in Configuring Ownership and access to a service account.

Authenticating via Workload Identity Federation

jobs:
  job_id:
    permissions:
      contents: 'read'
      id-token: 'write'

    steps:
    - uses: actions/checkout@v3
    - id: 'auth'
      uses: 'google-github-actions/auth@v0'
      with:
        workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
        service_account: '[email protected]'

    - name: 'Deploy to Cloud Run'
      uses: 'google-github-actions/deploy-cloudrun@v0'
      with:
        image: 'gcr.io/cloudrun/hello'
        service: 'hello-cloud-run'

Authenticating via Service Account Key JSON

jobs:
  job_id:
    steps:
    - id: 'auth'
      uses: 'google-github-actions/auth@v0'
      with:
        credentials_json: '${{ secrets.GCP_SA_KEY }}'

    - name: 'Deploy to Cloud Run'
      uses: 'google-github-actions/deploy-cloudrun@v0'
      with:
        image: 'gcr.io/cloudrun/hello'
        service: 'hello-cloud-run'

Via Application Default Credentials

If you are hosting your own runners, and those runners are on Google Cloud, you can leverage the Application Default Credentials of the instance. This will authenticate requests as the service account attached to the instance. This only works using a custom runner hosted on GCP.

jobs:
  job_id:
    steps:
    - name: 'Deploy to Cloud Run'
      uses: 'google-github-actions/deploy-cloudrun@v0'
      with:
        image: 'gcr.io/cloudrun/hello'
        service: 'hello-cloud-run'

Example Workflows

Migrating from setup-gcloud

Example using setup-gcloud:

jobs:
  job_id:
    steps:
    - name: 'Setup Cloud SDK'
      uses: 'google-github-actions/setup-gcloud@v0'
      with:
        project_id: '${{ env.PROJECT_ID }}'
        service_account_key: '${{ secrets.GCP_SA_KEY }}'

    - name: 'Deploy to Cloud Run'
      run: |-
        gcloud run deploy $SERVICE \
          --region $REGION \
          --image gcr.io/$PROJECT_ID/$SERVICE \
          --platform managed \
          --set-env-vars NAME="Hello World"

Migrated to deploy-cloudrun:

jobs:
  job_id:
    steps:
    - id: 'auth'
      uses: 'google-github-actions/auth@v0'
      with:
        credentials_json: '${{ secrets.GCP_SA_KEY }}'

    - name: 'Deploy to Cloud Run'
      uses: 'google-github-actions/deploy-cloudrun@v0'
      with:
        service: '${{ env.SERVICE }}'
        image: 'gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}'
        region: '${{ env.REGION }}'
        env_vars: 'NAME="Hello World"'

Note: The action is for the "managed" platform and will not set access privileges such as allowing unauthenticated requests.

Versioning

We recommend pinning to the latest available major version:

- uses: 'google-github-actions/deploy-cloudrun@v0'

While this action attempts to follow semantic versioning, but we're ultimately human and sometimes make mistakes. To prevent accidental breaking changes, you can also pin to a specific version:

- uses: 'google-github-actions/[email protected]'

However, you will not get automatic security updates or new features without explicitly updating your version number. Note that we only publish MAJOR and MAJOR.MINOR.PATCH versions. There is not a floating alias for MAJOR.MINOR.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].