Pipery Cloud Run CD#

Reusable GitHub Action for Google Cloud Run deployment with structured logging via Pipery.

GitHub Marketplace Version License: MIT

Table of Contents#

Quick Start#

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

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pipery-dev/cloudrun-cd@v1.1.0
        with:
          image_name: gcr.io/my-project/my-service
          image_tag: ${{ github.sha }}
          service_name: my-service
          region: us-central1
          project_id: my-project

Pipeline Overview#

StepDescriptionSkip Input
PushPush Docker image to Artifact Registryskip_push
DeployDeploy to Cloud Run serviceskip_deploy
Status checkVerify service healthskip_status_check

Configuration Options#

NameDefaultDescription
project_path.Path to the project source tree.
config_file.pipery/config.yamlPath to Pipery config file.
image_name``Container image name to deploy (e.g., ghcr.io/org/app).
image_tag${{ github.sha }}Container image tag to deploy.
service_name``Cloud Run service name.
regionus-central1Google Cloud Run region.
project_id``Google Cloud project ID.
platformmanagedTarget platform: managed or gke.
traffic100Percentage of traffic to route to new revision (0-100).
min_instances0Minimum number of Cloud Run instances.
max_instances100Maximum number of Cloud Run instances.
concurrency80Maximum concurrent requests per instance.
log_filepipery.jsonlPath to write the JSONL log file.
skip_pushfalseSkip image push step.
skip_deployfalseSkip deploy step.
skip_status_checkfalseSkip health check step.

Usage Examples#

Example 1: Basic Cloud Run deployment#

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

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pipery-dev/cloudrun-cd@v1.1.0
        with:
          image_name: gcr.io/my-project/my-service
          image_tag: ${{ github.sha }}
          service_name: my-service
          region: us-central1
          project_id: my-project

Example 2: With custom scaling and concurrency#

- uses: pipery-dev/cloudrun-cd@v1.1.0
  with:
    image_name: gcr.io/my-project/my-service
    image_tag: ${{ github.sha }}
    service_name: my-service
    region: us-central1
    project_id: my-project
    min_instances: "2"
    max_instances: "50"
    concurrency: "100"

Example 3: Blue-green deployment with gradual traffic shift#

- uses: pipery-dev/cloudrun-cd@v1.1.0
  with:
    image_name: gcr.io/my-project/my-service
    image_tag: ${{ github.sha }}
    service_name: my-service
    region: us-west1
    project_id: my-project
    traffic: "50"

Example 4: Multiple regions deployment#

- uses: pipery-dev/cloudrun-cd@v1.1.0
  with:
    image_name: gcr.io/my-project/my-service
    image_tag: ${{ github.sha }}
    service_name: my-service-us
    region: us-central1
    project_id: my-project

- uses: pipery-dev/cloudrun-cd@v1.1.0
  with:
    image_name: gcr.io/my-project/my-service
    image_tag: ${{ github.sha }}
    service_name: my-service-eu
    region: europe-west1
    project_id: my-project

Example 5: GKE-hosted Cloud Run#

- uses: pipery-dev/cloudrun-cd@v1.1.0
  with:
    image_name: gcr.io/my-project/my-service
    image_tag: ${{ github.sha }}
    service_name: my-service
    region: us-central1
    project_id: my-project
    platform: gke

Example 6: Skip health checks for faster deployment#

- uses: pipery-dev/cloudrun-cd@v1.1.0
  with:
    image_name: gcr.io/my-project/my-service
    image_tag: ${{ github.sha }}
    service_name: my-service
    region: us-central1
    project_id: my-project
    skip_status_check: true

GitLab CI#

Use the GitLab mirror template when .gitlab-ci.yml is published for this pipeline family. Import it from the mirrored GitLab project or use it as a reference implementation for running the same Pipery pipeline outside GitHub Actions.

The GitLab pipeline maps action inputs to CI/CD variables, publishes pipery.jsonl as an artifact, and maintains the same skip controls. Store credentials as protected GitLab CI/CD variables.

include:
  - project: pipery-dev/cloudrun-cd
    ref: v1.1.0
    file: /.gitlab-ci.yml

GitLab CI Variables#

Configure these protected variables in Settings > CI/CD > Variables:

  • GCLOUD_SERVICE_KEY_BASE64 - GCP service account key (base64-encoded)
  • GCP_PROJECT_ID - Google Cloud project ID
  • CLOUDRUN_SERVICE - Cloud Run service name
  • CLOUDRUN_REGION - Deployment region (default: us-central1)

Bitbucket Pipelines#

Bitbucket Cloud pipelines provide an alternative to GitHub Actions. Use Bitbucket shared pipeline imports to reference the exported Pipery pipeline instead of copying YAML into every application repository.

Getting Started#

  1. Add a Bitbucket import source for the shared Pipery pipeline and import the exported pipeline by name:
definitions:
  imports:
    pipery-shared: pipery-dev/cloudrun-cd:v1.1.0
    pipery-custom: pipery-dev/cloudrun-cd:v1.1.0:.bitbucket/shared-pipelines.yml

pipelines:
  branches:
    main:
      import: pipery-cloudrun-cd@pipery-shared

  custom:
    run-pipery:
      import: pipery-cloudrun-cd@pipery-custom

Use {project-path}/{repo-slug}:{branch-or-tag} for a shared repository bitbucket-pipelines.yml, or {project-path}/{repo-slug}:{branch-or-tag}:{config-filepath} for another exported YAML file.

  1. Configure Protected Variables in Repository Settings > Pipelines > Repository Variables:
    • GCLOUD_SERVICE_KEY_BASE64 - GCP service account key
    • GCP_PROJECT_ID - Google Cloud project ID
    • CLOUDRUN_SERVICE - Cloud Run service name
    • CLOUDRUN_REGION - Deployment region
  2. Commit to trigger deployment

Pipeline Stages#

The Bitbucket equivalent follows the same structure:

checkout → setup → push → deploy → status_check → logs

Features#

  • Artifact Registry image push
  • Managed and GKE Cloud Run support
  • Automatic traffic shifting
  • Instance and concurrency scaling
  • Health checks and monitoring
  • Multi-region deployments
  • JSONL-based pipeline logging
  • 90-day log retention

About Pipery#

Pipery Pipery is an open-source CI/CD observability platform. Every step script runs under psh (Pipery Shell), which intercepts all commands and emits structured JSONL events — giving you full visibility into your pipeline without any manual instrumentation.

Development#

# Run the action locally against test-project/
pipery-actions test --repo .

# Regenerate docs
pipery-actions docs --repo .

# Dry-run release
pipery-actions release --repo . --dry-run