Streamlining TypeScript Deployments: GitHub Actions to Google Cloud Run

Automating deployments is a cornerstone of efficient software development. For our learn-cicd-typescript-starter project, the goal was to achieve seamless, continuous delivery of our application to a robust serverless platform.

The Challenge

Manually deploying application updates, especially for a continuously evolving project, can be time-consuming and error-prone. We needed a reliable, automated pipeline to take our TypeScript application from a Git push directly to a live environment. Google Cloud Run offers an excellent serverless platform for containerized applications, but integrating it effectively into a Continuous Delivery (CD) workflow requires a well-orchestrated process.

The Solution: GitHub Actions & Google Cloud Run

The solution involved leveraging GitHub Actions to build, authenticate, and deploy our containerized TypeScript application to Google Cloud Run. This approach ensures that every change pushed to our repository automatically triggers a deployment, reducing manual overhead and increasing deployment frequency and reliability. The workflow encapsulates the entire process: fetching the code, building a Docker image, pushing it to a container registry, authenticating with Google Cloud, and finally deploying the new image to a specified Cloud Run service.

An Example of What's Deployed

While the GitHub Action orchestrates the deployment, the actual application being deployed is a TypeScript-based project, which often includes static assets and user interfaces. Here's a simplified HTML snippet that represents a basic landing page that might be part of our learn-cicd-typescript-starter project, demonstrating what gets delivered to users once deployed to Cloud Run:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TypeScript Starter App</title>
    <style>
        body { font-family: Arial, sans-serif; text-align: center; margin-top: 50px; }
        h1 { color: #333; }
        p { color: #666; }
    </style>
</head>
<body>
    <h1>Welcome to Our TypeScript Starter!</h1>
    <p>This application is successfully deployed on Google Cloud Run via GitHub Actions.</p>
    <p>Version: 1.0.0</p>
</body>
</html>

This index.html file would be served by our TypeScript application running in a Docker container on Cloud Run, providing immediate feedback that the deployment was successful and the application is live.

The Deployment Workflow

The core of the CD pipeline is a GitHub Actions workflow. When code is pushed to the repository, the workflow activates. It first checks out the code, then proceeds to build a Docker image of the TypeScript application. This image is tagged and pushed to a container registry, typically Google Container Registry (GCR) or Artifact Registry. Following this, the workflow authenticates to Google Cloud Platform using service account credentials. Finally, it uses the authenticated context to deploy the newly built and pushed container image to our designated Google Cloud Run service, automatically handling revisions and traffic management. This sequence ensures a fully automated and traceable deployment process.

The Impact

Implementing this CD pipeline significantly improved our development feedback loop. Deployments are now fast, consistent, and require no manual intervention, freeing up developers to focus on writing code rather than managing releases. This automation dramatically reduces the risk of human error and ensures that our learn-cicd-typescript-starter project can evolve rapidly and reliably.

Moving forward, we'll continue to refine our CI/CD processes, ensuring our deployments are as efficient and robust as possible, making the journey from commit to production smooth and predictable.


Generated with Gitvlg.com

Streamlining TypeScript Deployments: GitHub Actions to Google Cloud Run
A

Ana Villanueva

Author

Share: