Skip to main content

Deploy via Git Repository

Cloud Run supports application deployment by binding personal or private Git repositories such as GitHub and GitLab, as well as direct deployment via public Git repository URLs. The applicable scenarios and operational procedures vary slightly between these two approaches:

Public Repository Deployment

  • Directly enter the public Git repository URL (no authorization required), such as open-source projects on GitHub/Gitee.
  • Suitable for open-source projects and scenarios without confidentiality and access control requirements.
  • The operational approach is similar to that of private repositories, but does not require account authorization, making it ideal for quick trials and sharing.

Operation Process

  1. In the Cloud Run console, choose "Deploy via public Git repository URL".
  2. Enter the public repository URL and branch, and configure parameters such as the access port.
  3. Save and start the deployment.

Private Repository Deployment

  • Requires authorization to bind GitHub, GitLab, and other accounts, and supports private and personal repositories.
  • Supports branch selection, build parameter configuration, and automated deployment triggering (e.g., push, PR merge, etc.).
  • Suitable for scenarios such as team collaboration, continuous integration (CI/CD), and automated deployment.
  • Can implement more complex automated workflows in conjunction with Webhooks and CI tools.

Operation Process

  1. In the Cloud Run console, choose "Deploy via Git repository".
  2. Bind your GitHub, GitLab, and other code repository accounts.
  3. Select the private or personal repository and branch to deploy, and configure the build parameters.
  4. Configure automated trigger rules (e.g., push, PR merge, etc.).
  5. Save and start the deployment.

Enable Automatic Deployment

The greatest advantage of private repositories is supporting the automatic deployment feature:

  1. On the service creation or update page, enable the "Automatic Deployment" option.
  2. The system will automatically configure a Webhook on the Git platform.
  3. After that, when there is a new code commit to the specified branch:
    • Webhook will automatically trigger the deployment process on Cloud Run
    • The system pulls the latest code and builds a new version
    • Automatically deploys the new version to the production environment

After configuration, each subsequent code change (e.g., push, PR merge) will automatically trigger new builds and deployments, significantly improving development efficiency.

Continuous Deployment Best Practices

Branch Policy

  • Development branch: Used for daily development work and does not trigger automatic deployment.
  • Test branch: Can be configured for automatic deployment to the test environment.
  • Main branch: Configured for automatic deployment to the production environment, typically master or main

Process Recommendations

  1. Perform feature development and unit testing on the development branch
  2. Merge code into the test branch via Pull Request/Merge Request
  3. Automatically deploys to the test environment and performs integration testing
  4. After the tests pass, merge the code into the main branch
  5. Automatically deploys to the production environment

Deployment Security

  • Before enabling automatic deployment, ensure that the Dockerfile has been fully tested
  • Configure an appropriate build timeout to prevent abnormal builds from occupying resources
  • Regularly check deployment logs to ensure the deployment process is normal
  • Retain multiple historical versions to enable quick rollbacks when issues arise with new versions

Fault Handling

  • If the service is abnormal after automatic deployment, you can quickly roll back to the previous stable version in the CloudRun console
  • Check the build logs and application logs to locate the cause of the issue
  • After fixing the issue, recommit the code to trigger a new deployment

Note: When using the automatic deployment feature for the first time, it is recommended to test it on non-critical services. Familiarize yourself with the entire process before applying it to core services.


Open Source Project Examples

Project (GitHub)DescriptionOne-Click Deployment Link
AI GatewayPortkey AI Gateway, an open-source AI gateway that supports multi-model routing and security control.One-click deployment
jsoncrackAn open-source tool for visualizing JSON structures, supporting interactive editing and sharing.One-Click Deployment

如需详细操作指引,请参考云托管平台相关文档或联系技术支持。