Court
02/18/2025, 3:58 PMMarvin
02/18/2025, 4:39 PMyaml
name: Deploy to Google Cloud Run
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install prefect
- name: Configure GCP Credentials
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
- name: Deploy to Cloud Run
run: |
gcloud run deploy my-service \
--image=<http://gcr.io/${{|gcr.io/${{> secrets.GCP_PROJECT_ID }}/my-image \
--region=${{ secrets.GCP_REGION }}
- name: Deploy Prefect Flow
run: |
prefect deploy
### Explanation
- Checkout code: Uses the actions/checkout
action to pull your repository's code.
- Set up Python: Configures the Python environment using actions/setup-python
.
- Install dependencies: Installs Prefect and any other Python dependencies.
- Configure GCP Credentials: Uses google-github-actions/setup-gcloud
to authenticate with Google Cloud using secrets from your GitHub repository.
- Deploy to Cloud Run: Deploys your service to Google Cloud Run using gcloud
commands.
- Deploy Prefect Flow: Uses prefect deploy
to manage deployment of Prefect flows.
### Additional Resources
- Prefect CI/CD Deployment Guide
- Prefect Google Cloud Worker Guide
This setup assumes you're using Prefect 3.x and have configured your prefect.yaml
file appropriately. Adjust the YAML as needed based on your specific project structure and requirements.