DEV Community

Evan Lin
Evan Lin

Posted on • Originally published at evanlin.com on

[Tutorial] CI/CD Architecture for a Hugo Blog on Cloud Run

title: [Learning Document] CICD Architecture for Setting Up a Hugo Blog via Cloud Run
published: false
date: 2022-02-05 00:00:00 UTC
tags: 
canonical_url: http://www.evanlin.com/til-hugo-cloudrun/
---

![image-20220207094450910](http://www.evanlin.com/images/2021/image-20220207094450910.png)

## Preface:

I had previously considered moving my blog to GCP. I happened to have some credits to use. I looked for articles on how to set up a Hugo blog on GCP. I saw that the official documentation had an article on using Cloud Run as a Hugo host. Here, I will simply update the latest interface and translate it into Chinese for your reference.

In fact, even after running through the process, there are still some follow-up steps:

- Modify DNS
- Migrate Jekyll to Hugo

These are covered in other articles.

## Process:

The process mostly follows [Automatic Deployment of Hugo Sites on Firebase Hosting and Drafts on Cloud Run](https://developers.googleblog.com/2020/08/automatic-deployment-of-hugo-sites-on-firebase-hosting.html) and is adapted into a Chinese version.

### 1. Set up a new Hugo project

Fork the relevant GitHub project [GitHub copy](https://github.com/jamesward/hello-hugo/fork) (i.e. fork)

[https://github.com/jamesward/hello-hugo](https://github.com/jamesward/hello-hugo)

### 2. Create Cloud Run

![image-20220207134534940](http://www.evanlin.com/images/2021/image-20220207134534940.png)

- Set up with Cloud Build
- Connect to Github repository
- Reguib, remember to select Taiwan “asia-east1 (Taiwan)”
- Select the project you forked

![image-20220207134616577](http://www.evanlin.com/images/2021/image-20220207134616577.png)

- Branch configuration –> `^master$` is set to the Master branch.
- Build Type, first select -> Dockerfile, which will need to be changed later

### Modify Continuous Deployment

![image-20220207153151826](http://www.evanlin.com/images/2021/image-20220207153151826.png)

You will find that this time it failed, then click "Edit Deployment"

![image-20220207153235138](http://www.evanlin.com/images/2021/image-20220207153235138.png)

### Edit Trigger - Event

- Event

![image-20220207153319290](http://www.evanlin.com/images/2021/image-20220207153319290.png)

### Edit Trigger - Configuration

![image-20220207153440164](http://www.evanlin.com/images/2021/image-20220207153440164.png)

- Location –> Repository
- Remember to change the file to `cloudbuild-draft.yaml`

### Create Firebase as a Production / CDN’d site

To setup your production / CDN’d site, [login to the firebase console](https://console.firebase.google.com/)

After starting, configure the relevant project.

### Modify Github to start the project

1. Modify to the Taiwan region –> asia-east1, refer to [commit](https://github.com/kkdai/hello-hugo/commit/9ca8ee11fc1237b92aabd6d5952d4d0074fba9f8)

![image-20220207153803757](http://www.evanlin.com/images/2021/image-20220207153803757.png)

1. Modify the Firebase Production project name (remember to change it to your project) Refer to [commit](https://github.com/kkdai/hello-hugo/commit/ed0ce403325fe69a0d6819d9293caeb3ab09619e)

![image-20220207153915314](http://www.evanlin.com/images/2021/image-20220207153915314.png)

### Final product

![image-20220207094444681](http://www.evanlin.com/images/2021/image-20220207094444681.png)

You will find that there are two Cloud Runs, one is the Trigger you set up. The second `hugo-site` is the Cloud Run that runs the CICD through the settings.

![image-20220207133557965](http://www.evanlin.com/images/2021/image-20220207133557965.png)

After clicking in, you will see a complete URL at the top, which is the external website address.

Final website: [https://hello-hugo-master-khga4c2v3a-de.a.run.app](https://hello-hugo-master-khga4c2v3a-de.a.run.app)

## Related Articles:

- [Automatic Deployment of Hugo Sites on Firebase Hosting and Drafts on Cloud Run](https://developers.googleblog.com/2020/08/automatic-deployment-of-hugo-sites-on-firebase-hosting.html)
- [Google CloudRun builds a Hugo static website environment and pairs it with CICD for continuous deployment, pay as you go, no basic fees](https://www.minwt.com/website/server/22837.html)
- [Running a Hugo generated site on Github Pages and Google Cloud Storage](https://tunzor.github.io/posts/hugo-on-gh-and-gcs/)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)