Add gitea and woodpecker CI
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Kaan Barmore-Genç 2022-11-19 12:50:50 -05:00
parent 961442207c
commit 03fb624f8c
Signed by: kaan
GPG key ID: B2E280771CD62FCF
3 changed files with 67 additions and 11 deletions

7
.vscode/tasks.json vendored
View file

@ -14,13 +14,6 @@
"type": "shell", "type": "shell",
"command": "hugo -D", "command": "hugo -D",
"problemMatcher": [] "problemMatcher": []
},
{
"label": "publish",
"type": "shell",
"command": "rsync -av ./public/ /var/www/",
"problemMatcher": [],
"dependsOn": "build"
} }
] ]
} }

View file

@ -5,7 +5,7 @@ draft: false
toc: false toc: false
images: images:
tags: tags:
- untagged - homelab
--- ---
I've recently switched to [Kopia](https://kopia.io/) after having some trouble with Duplicati. There I've recently switched to [Kopia](https://kopia.io/) after having some trouble with Duplicati. There
@ -62,4 +62,3 @@ gitignores. I have 13 snapshots of this, which in total take up 4.9GB on disk.
I have Kopia set up to use pgzip compression which seems to be the best option I have Kopia set up to use pgzip compression which seems to be the best option
in terms of compression speed versus storage size. in terms of compression speed versus storage size.

View file

@ -0,0 +1,64 @@
---
title: "Automating My Blog With Gitea and Woodpecker"
date: 2022-11-19T12:21:40-05:00
toc: false
images:
tags:
- 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](https://woodpecker-ci.org/). 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](https://gitea.bgenc.net/kaan/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](https://gitea.bgenc.net/kaan/bgenc.net)! 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](https://woodpecker-ci.org/docs/next/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.