How to Automate a GCP Deploy by GitHub New Tag
Silvio Ubaldino
Fullstack Software Engineer | Backend Developer | Golang | Java | Microservices | SQL | NoSQL | React | Docker | AWS
Automating deployments can significantly improve the speed and reliability of delivering your applications. In this article, I’ll share how I configured Google Cloud Platform (GCP) to automatically deploy my app whenever a new GitHub tag is pushed. Using regex, we’ll redirect each pattern to the appropriate environment, ensuring a seamless and organized workflow.
Creating an Environment in Google Cloud Run
To set up an environment in Google Cloud Run, follow these steps:
Creating a GCP Trigger
Triggers in GCP allow you to define automated actions based on specific events. Here’s how you create one for new GitHub tags:
For staging (testing environment), use ^\d+\.\d+\.\d+-.*, which matches tags like 0.0.0-20241112-update or 1.1.0-rc.1.
For production, use ^\d+\.\d+\.\d+$, which matches tags like 1.0.0, 1.0.1, or 1.1.0.Build configuration: Set the build steps, such as containerizing the application or deploying it to Cloud Run.
领英推荐
The tagging follows the Semantic Versioning (SemVer) standard, which organizes versions into major, minor, and patch levels (e.g., 1.0.0). The addition of suffixes like -rc.1 or -<date>-update helps manage pre-release versions for staging.
Creating a New Tag
To test your setup, create a new tag in your GitHub repository:
Open your terminal and navigate to the repository:
git tag v1.0.0
git push origin v1.0.0
For a staging environment, you could create:
git tag 1.1.0-rc.1
git push origin 1.1.0-rc.1
Once the tag is pushed, the trigger will activate, deploying your app to the corresponding environment based on the regex.
Senior .NET Software Engineer | Senior Full Stack Developer | C# | .Net Framework | Azure | React | SQL | Microservices
3 个月Great content, thanks for sharing!
.NET Software Engineer | Full Stack Developer | C# | Angular | AWS | Blazor
3 个月Very informative, thanks for sharing!
Data Analyst & Insights Specialist | SQL & Database Expert | Power BI Specialist | DBA
3 个月Very good, congratulations Silvio Ubaldino
Great tips, thanks!!