DEV Community

Cover image for Automating Go App Deployment to Google Cloud Run with GitHub Actions(Free Tier)
Asuka Suehiro
Asuka Suehiro

Posted on

Automating Go App Deployment to Google Cloud Run with GitHub Actions(Free Tier)

Hi, everyone! This is my first article on dev.to.πŸ‘‹
I recently built a Go application and deployed it, using Google Cloud Run and GitHub Actions to deepen my DevOps skills. In this post, I'll share how I automated the deployment process and what I learned along the way.

Background

I currently live in Canada but earn my salary in JPY. Since the exchange rate fluctuates constantly, checking the CAD/JPY rate manually every day has been a hassle. I wanted a system that would automatically notify me via Slack whenever the rate improved compared to the day before. To achieve this, I decided to autmate the workflow, using GCP and GitHub Actions.

The System Architechture

graph LR
  GitHub[GitHub] --> Actions[GitHub Actions]
  Actions --> Registry[Artifact Registry]
  Registry --> CloudRun[Cloud Run]
  Scheduler[Cloud Scheduler] --> CloudRun
Enter fullscreen mode Exit fullscreen mode

Why these technologies?

  • Why Go?: It's a static typed language, which ensures robustness and keep the container image size small.
  • Why Google Cloud Run?: It's a serverless platform, so I don't need to manage severs. Plus, it scales to zero when not in use, allowing me to run this bot within the Free Tier.
  • Why GitHub Actions?: It allows me to manage CI/CD pipeline at right next to my code. Integrating it with GCP is secure and seamless.

Key Challenges & Solutions

  • The "Secure by Default" Trap (403 Forbidden): At first, I didn't realize that Google Cloud Run blocks unauthenticated access by default and focused on 403 Forbidden errors without allowing unauthenticated invocations. I set OIDC Token in Cloud Scheduler Authentication Header.
  • CI/CD Configuration Details: I spent Time debugging The GitHub Actions pipeline because of a simple mismatch in the Artifact Registry configuration. I confused the Repository Name with the Repository ID. This experience taught me that in DevOps, paying attention to the smallest details in variable names is just as important as writing the code itself.

What I Learned

The Trade-off: Initial Setup Pain vs. Future Efficiency### Future Improvements
Runnning code locally is intuitive and instant, while moving to the cloud felt tedious. But once I overcame that initial barrier, I realized the power of automation. The system now works for me, while I sleep. I learned that engineering is about enduring the initial struggle of setup to achieve long-term efficiency. This project allows me to save time to do something else to improve my skill - which I believe is the essence of technological progress.

Future Improvements

  • Database Integration: I plan to use PostgreSQL(with Atlas) to store historical rate data.
  • Data Analysis: I want to build a Python component to analyze the rate trends using Pandas and visualize the data.

πŸ”— Links

Top comments (0)