bgenc.net/content/posts/2022.11.19.automating-my-blog-with-gitea-and-woodpecker.md
Kaan Barmore-Genç 03fb624f8c
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Add gitea and woodpecker CI
2022-11-19 12:50:50 -05:00

3.5 KiB

title date toc images tags
Automating My Blog With Gitea and Woodpecker 2022-11-19T12:21:40-05:00 false
homelab

I had been using Gitea for a while. If you haven't heard of it before, it's a "git forge" meaning a website where you can host git repositories, track issues, accepts pull requests and so on. If you have seen Github, it's just like that. My Gitea is for personal use only, but I do keep it accessible publicly: https://gitea.bgenc.net/

I have been using this personal instance to keep a few small experiments and my personal blog, but one thing I've found missing was a CI. Again in case you are unfamiliar, CIs are tools that automate processes in your projects. For example, you could automate a testing process so the code gets tested every time a pull request is created. Or automate a release so the code gets built and uploaded when a new version is tagged on git.

I hadn't looked into a CI since I wasn't using my Gitea for anything important, and for any "big" project I could just use Github and get their free Github Actions for public repositories. But I recently started working on some projects I'd rather keep private, and thought that having a CI to automate testing on them would be useful.

After looking around for a CI and not finding a lot that I like, I came across Woodpecker CI. Woodpecker is a relatively simple CI system: it's all built on top of Docker and runs everything in containers. You specify your actions as container images and steps to be executed inside those images... and that's all!

Setting up Woodpecker and connecting it to Gitea was a breeze, you just point a few variables to Gitea and create an app on Gitea, then you're done! It uses OAuth to log you into Woodpecker through Gitea, and automatically grabs all your repositories. All you have to do is hit enable on Woodpecker, then add a .woodpecker.yml to your repository.

I ended up trying out Woodpecker with 2 repositories:

  • The first is a containers repository: I realized that I might need to create some simple container images to use in my Woodpecker pipelines so this is a repository to keep these simple images. The containers are also automatically built with Woodpecker: there's a Woodpecker plugin (the plugin itself is a container too!) to build and publish docker containers so the process is trivial.
  • The second is this blog! I used to just manually run the build for this and rsync it over to my server. But with Woodpecker I was able to automate this process. Using a hugo container, the blog gets built. Then I use a container I created to then rsync it over to my server. I created a special system user that has ownership over the www folder, who can only log in with an SSH key that's stored as a Woodpecker secret.

The whole process absolutely amazed me! Woodpecker is missing a few minor features I would have liked, like the ability to trigger builds with a click (like github actions workflow_dispatch option) or to trigger builds with a timer. A timer would have been especially useful with my containers repository to keep all the containers up to date. But I imagine this will be possible eventually. At the very least, it looks like they are working on a CLI for the next version of Woodpecker which can start pipelines, so it would be possible to set up a timer with a bit of scripting.