~ git clone https://git.cass.si/deploy-cloud-run.git
~ git clone https://git.cass.si/deploy-cloud-run.git
A GitHub Action that automates building Docker images using Google Cloud Build and deploying them to Google Cloud Run with Slack notifications.
This action provides a complete CI/CD pipeline for deploying containerized applications to Google Cloud Run. It handles:
- name: Build & Deploy to Cloud Run
uses: ./.github/actions/deploy-cloud-run
env:
APPLICATION: "my-app"
ENVIRONMENT: "production"
SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }}
SLACK_DEPLOYMENTS_CHANNEL: ${{ secrets.SLACK_DEPLOYMENTS_CHANNEL }}
with:
# Required inputs
gcp-project-id: my-project-id
gcp-service-account-key: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
gcp-cloud-storage-bucket: my-build-bucket
gcp-artifact-registry-repository: my-registry
gcp-cloud-run-service-name: my-service
gcp-cloud-run-port: 8080
image-name: my-app
image-sources: "src,package.json,Dockerfile"
# Optional inputs
gcp-cloud-build-machine-type: E2_HIGHCPU_32
gcp-cloud-run-scaling-min-max: "0,10"
gcp-cloud-run-resources-cpu-mem: "2,1Gi"
gcp-cloud-run-max-concurrency: 80
gcp-cloud-run-cpu-idle: true
gcp-secrets-manager-secret-id: my-secret
gcp-secrets-manager-secret-env-key: API_KEY
image-path: ./Dockerfile
image-tag-format: $BRANCH-$SHA
image-tag-latest: true
image-tag-additional-tags: "stable,v1.0.0"
| Input | Description |
|---|---|
gcp-project-id |
The GCP Project ID |
gcp-service-account-key |
Base64-encoded service account key file |
gcp-cloud-storage-bucket |
Cloud Storage bucket for temporary build files |
gcp-artifact-registry-repository |
Artifact Registry repository name |
gcp-cloud-run-service-name |
Cloud Run service name |
gcp-cloud-run-port |
Container port to expose |
image-name |
Name of the Docker image |
image-sources |
Comma-separated list of files/folders to include in build |
| Input | Default | Description |
|---|---|---|
gcp-cloud-build-machine-type |
- | Cloud Build machine type (e.g., E2_HIGHCPU_32) |
gcp-cloud-run-resources-cpu-mem |
1,512Mi |
CPU and memory allocation (e.g., "4,2Gi") |
gcp-cloud-run-scaling-min-max |
- | Min and max instances (e.g., "0,10") |
gcp-cloud-run-max-concurrency |
- | Max concurrent requests per instance |
gcp-cloud-run-cpu-idle |
- | Scale to zero when idle |
gcp-cloud-run-region |
europe-west2 |
Cloud Run deployment region |
gcp-artifact-registry-region |
europe-west2 |
Artifact Registry region |
gcp-secrets-manager-secret-id |
- | Secrets Manager secret to reference |
gcp-secrets-manager-secret-env-key |
- | Environment variable name for the secret |
gcp-vpc-connector-name |
- | VPC connector name for network access |
image-path |
./Dockerfile |
Path to Dockerfile |
image-tag-format |
$BRANCH-$SHA-$YYYY.$MM.$DD-$HH.$mm.$SS |
Custom tag format |
image-tag-latest |
false |
Tag image as "latest" |
image-tag-additional-tags |
- | Comma-separated list of additional tags |
$BRANCH - Normalized branch name$SHA - 7-digit commit SHA$YYYY - Year (4 digits)$MM - Month (2 digits)$DD - Day (2 digits)$HH - Hour (2 digits, 24h format)$mm - Minute (2 digits)$SS - Second (2 digits)| Output | Description |
|---|---|
full-image-name |
Full image name with host, project ID, and image name (without tags) |
image-tags |
Comma-separated list of tags applied to the built image |
cloud-run-uri |
URI of the deployed Cloud Run service |
The action requires the following environment variables:
APPLICATION: Name of the application being deployedENVIRONMENT: Deployment environment (e.g., staging, production)SLACK_BOT_TOKEN: Slack bot OAuth tokenSLACK_DEPLOYMENTS_CHANNEL: Slack channel ID for notificationsnpm install
npm run build
This compiles TypeScript to JavaScript and bundles the action using esbuild.
npm run lint # Check for issues
npm run lintFix # Auto-fix issues
For issues or questions, please open an issue in the repository.