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

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

Source: Dev.to

Background ## The System Architechture ## Why these technologies? ## Key Challenges & Solutions ## What I Learned ## Future Improvements ## 🔗 Links 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. 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 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. Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse COMMAND_BLOCK: 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 COMMAND_BLOCK: graph LR GitHub[GitHub] --> Actions[GitHub Actions] Actions --> Registry[Artifact Registry] Registry --> CloudRun[Cloud Run] Scheduler[Cloud Scheduler] --> CloudRun COMMAND_BLOCK: graph LR GitHub[GitHub] --> Actions[GitHub Actions] Actions --> Registry[Artifact Registry] Registry --> CloudRun[Cloud Run] Scheduler[Cloud Scheduler] --> CloudRun - 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. - 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. - 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. - GitHub Repository: https://github.com/kskiii/yenup-app