This repository is a template for deploying a Python (FastAPI) application to Google Cloud Run using GitHub Actions.
Gabriel Carvalho
- Framework: FastAPI
- Deployment: Google Cloud Run
- CI/CD: GitHub Actions (
.github/workflows/cloud-run-deploy.yaml)
To enable automatic deployment via GitHub Actions, you must set the following secrets in your repository:
| Secret Name | Description |
|---|---|
GCP_PROJECT_ID |
Your Google Cloud Project ID |
GCP_REGION |
The region where your Cloud Run service will be deployed |
GCP_SA_EMAIL |
Service Account email with permissions to deploy to Cloud Run |
SA_KEY |
JSON key for the Service Account (as a string) |
ARTIFACT_REGISTRY_HOSTNAME |
Hostname of your Artifact Registry (e.g., us-central1-docker.pkg.dev) |
ARTIFACT_REGISTRY_REPO |
Name of your Artifact Registry repository |
You can set these secrets in your repository settings under Settings > Secrets and variables > Actions.
- Clone this repository
- Set the required secrets as described above
- Push your code to the
mainbranch - The GitHub Actions workflow will automatically build and deploy your app to Cloud Run
To run the FastAPI app locally:
pip install -r requirements.txt
python app/main.pyThe app will be available at http://localhost:8000/.
MIT