Musselman Development

Automating Blog Deployment Using Forgejo Actions

Reading Time: 2 minutes

Recently I have been dedicating a bit of each day to work on programming projects to give me a break from job hunting. With most programming projects that I have done in the past year or so I have used Jenkins for CI/CD to automate and run tests on my codebases. It was temperamental at best, and causing issues system-wide at worst, so I decided it was time to move on shortly after the end of my senior capstone. The question was what to replace it with.

About two days into my search for a replacement I found Forgejo Actions. As I currently already run my own Forgejo instance it sounded like a shoe in. For some, Forgejo Actions may sound reminiscent of the similarly named GitHub Actions, and it works in much the same way. As a simple starter project I attempted to automate the deployment of my websites. It was a relatively minor challenge to get working, so I thought I would share my solution for others to possibly learn from and use. Below is the current Forgejo workflow for deploying the site you are reading.

on: [push]
jobs:
  deploy:
    runs-on: website
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup Go
        uses: actions/setup-go@v5
        with:
          go-version: '>=1.22.0'
      - name: Setup Hugo
        uses: https://github.com/peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.119.0'
          extended: true
      - name: Build
        run: hugo
      - name: Deploy
        run: cp -r public/ /websites/musselman.dev

The current setup is using a shared directory (/websites/musselman.dev/) and caddy to instantly deploy to the live site. This is ok for me due to the fact that most content is reviewed using hugo serve before even being pushed to the repository. If I find issues with it, or a better way to safely set up this automation I will update the article.

If you have any feedback or found this useful please reach out to me using one of the methods in the author information box below.

Tags: Forgejo Blogging CI/CD