No repo secrets: unsigned image, updates as release assets, job image built by mkosi
os / os (push) Successful in 3m51s

The workflow's own token can't write packages and repo secrets can't be
set, so: build unsigned, publish the sysupdate files as assets of the
"latest" release, and build the job image with mkosi and ship it in /usr
instead of pushing it to a registry. Partition UUIDs are now part of the
update file names, so updated /usr partitions keep the UUIDs usrhash=
expects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Job79andClaude Opus 5.5 committed 2026-11-12 23:21:42 +01:00
1 parent d4eebeb01f
commit dfa5d69b44
16 files changed
+107 -108

No files matched your search

-28
View File
@@ -1,28 +0,0 @@
# git-runner job image
#
# Builds the job image (job/) and pushes it to this Gitea's registry.
# Runs on every push, weekly for Fedora updates, and by hand.
name: job
on:
push:
branches: [main]
schedule:
- cron: "0 2 * * 0" # weekly (Sunday), picks up Fedora updates
workflow_dispatch: # run by hand, e.g. for a CVE
jobs:
job:
runs-on: fedora
env:
IMAGE: git.plabble.org/job79/git-runner-mkosi-job:latest
steps:
- name: Install tools
run: dnf install -yq git-core podman
- name: Check out
uses: builtin:checkout
- name: Build
run: podman build -t "$IMAGE" job
- name: Log in to the registry
run: podman login -u "${{ github.repository_owner }}" --password-stdin git.plabble.org <<<"${{ secrets.GITHUB_TOKEN }}"
- name: Push
run: podman push --compression-format=zstd:chunked "$IMAGE"
+21 -21
View File
@@ -1,13 +1,9 @@
# git-runner OS image
#
# Builds the OS image with mkosi, signed for Secure Boot, and publishes it in this Gitea's generic
# package registry, where runners fetch their updates (mkosi.extra/usr/lib/sysupdate.d):
# https://git.plabble.org/api/packages/job79/generic/git-runner-mkosi/latest/
# Builds the OS image, with the job image inside, and publishes it as assets of this repository's
# "latest" release, where runners fetch their updates (mkosi.extra/usr/lib/sysupdate.d).
# Runs on every push, weekly for Fedora updates, and by hand. The weekly and manual runs also
# publish the disk image for new installs (git-runner.qcow2 in the same place).
#
# Secrets:
# - SECUREBOOT_KEY the private key for mkosi.crt
# publish the disk image for new installs (git-runner.qcow2).
name: os
on:
push:
@@ -20,39 +16,43 @@ jobs:
os:
runs-on: fedora
env:
PACKAGE: https://git.plabble.org/api/packages/job79/generic/git-runner-mkosi/latest
AUTH: ${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }}
API: ${{ github.api_url }}/repos/${{ github.repository }}/releases
AUTH: "Authorization: token ${{ github.token }}"
steps:
- name: Install tools
run: dnf install -yq git-core mkosi jq
- name: Check out
uses: builtin:checkout
- name: Build
env:
SECUREBOOT_KEY: ${{ secrets.SECUREBOOT_KEY }}
run: |
(umask 077; printenv SECUREBOOT_KEY > mkosi.key)
mkosi --secure-boot=yes build
run: mkosi build
- name: Compress
working-directory: mkosi.output
run: |
zstd -q --rm -T0 -19 git-runner_*.usr-*.raw
sha256sum git-runner_*.efi git-runner_*.usr-*.raw.zst > SHA256SUMS
- name: Find the release
run: |
release=$(curl -fsS -H "$AUTH" "$API/tags/latest") ||
release=$(curl -fsS -H "$AUTH" -H 'Content-Type: application/json' "$API" -d '{"tag_name": "latest", "name": "latest"}')
echo "RELEASE=$API/$(jq .id <<<"$release")" >> "$GITHUB_ENV"
# Uploads the update, then replaces SHA256SUMS, which tells runners it is there.
- name: Publish the update
working-directory: mkosi.output
run: |
for f in $(awk '{print $2}' SHA256SUMS); do curl -fsS -u "$AUTH" --upload-file "$f" "$PACKAGE/$f"; done
curl -fsS -u "$AUTH" -X DELETE "$PACKAGE/SHA256SUMS" || true
curl -fsS -u "$AUTH" --upload-file SHA256SUMS "$PACKAGE/SHA256SUMS"
for f in $(awk '{print $2}' SHA256SUMS); do curl -fsS -o /dev/null -H "$AUTH" -F "attachment=@$f" "$RELEASE/assets?name=$f"; done
old=$(curl -fsS -H "$AUTH" "$RELEASE/assets" | jq '.[] | select(.name == "SHA256SUMS") | .id')
[ -z "$old" ] || curl -fsS -H "$AUTH" -X DELETE "$RELEASE/assets/$old"
curl -fsS -o /dev/null -H "$AUTH" -F attachment=@SHA256SUMS "$RELEASE/assets?name=SHA256SUMS"
- name: Remove older versions
working-directory: mkosi.output
run: |
curl -fsS -u "$AUTH" https://git.plabble.org/api/v1/packages/job79/generic/git-runner-mkosi/latest/files | jq -r '.[].name' | grep '^git-runner_' |
grep -vxFf <(awk '{print $2}' SHA256SUMS) | while read -r f; do curl -fsS -u "$AUTH" -X DELETE "$PACKAGE/$f"; done
curl -fsS -H "$AUTH" "$RELEASE/assets" | jq -r '.[] | "\(.id) \(.name)"' | grep ' git-runner_' |
grep -vFf <(awk '{print " " $2}' SHA256SUMS) | while read -r id name; do curl -fsS -H "$AUTH" -X DELETE "$RELEASE/assets/$id"; done
- name: Publish the disk image
if: github.event_name != 'push'
working-directory: mkosi.output
run: |
qemu-img convert -c -O qcow2 "$(basename git-runner_*.efi .efi).raw" git-runner.qcow2
curl -fsS -u "$AUTH" -X DELETE "$PACKAGE/git-runner.qcow2" || true
curl -fsS -u "$AUTH" --upload-file git-runner.qcow2 "$PACKAGE/git-runner.qcow2"
old=$(curl -fsS -H "$AUTH" "$RELEASE/assets" | jq '.[] | select(.name == "git-runner.qcow2") | .id')
[ -z "$old" ] || curl -fsS -H "$AUTH" -X DELETE "$RELEASE/assets/$old"
curl -fsS -o /dev/null -H "$AUTH" -F attachment=@git-runner.qcow2 "$RELEASE/assets?name=git-runner.qcow2"
+1 -2
View File
@@ -1,3 +1,2 @@
# Build outputs, and the Secure Boot key for local signed builds.
# Build outputs.
mkosi.output/
mkosi.key
+32
View File
@@ -0,0 +1,32 @@
# git-runner-mkosi
A [Gitea Actions](https://docs.gitea.com/usage/actions/overview) runner packaged as a minimal Fedora VM image, built with [mkosi](https://github.com/systemd/mkosi). It builds and publishes its own OS image, and keeps itself up to date.
- **Small:** Fedora with podman, networking and zram swap, for VMs only: no firmware or drivers for real hardware, no package manager or sshd.
- **Stateless:** container storage is wiped on every boot.
- **Isolated jobs:** each job runs in a container of its own (privileged, so it can build OS images), with its own podman; jobs never get the runner's podman. The job image ships with the OS, and common base images are shared read-only, so jobs don't download them.
- **Self-updating:** images are rebuilt weekly and on every push. Hosts download updates with systemd-sysupdate into a second /usr partition (A/B) and reboot into them daily at about 04:10, after letting running jobs finish.
- **Read-only /usr:** systemd-boot starts a UKI that mounts /usr from a read-only erofs partition, checked by dm-verity. /etc and /var live on the root partition, which updates keep.
- **Hardened:** a firewall that drops all incoming traffic, and KSPP sysctls and kernel arguments.
## Install
Download [the disk image](https://git.plabble.org/Job79/git-runner-mkosi/releases/download/latest/git-runner.qcow2) (built weekly by the `os` workflow), resize it to the disk size you want (the root partition grows to fill it) and boot it with UEFI. The console asks for a root password, hostname, Gitea URL, registration token and number of parallel jobs; the runner then registers itself.
## Images
| `runs-on` | Image |
|---|---|
| `linux` | Our job image (`mkosi.images/job/`): git, Node.js, skopeo, dnf and podman (also as `docker`) |
| `fedora` | Plain Fedora, used by our own build so a broken job image can't block its fix |
## Development
`mkosi.conf` defines the OS (`mkosi.extra/` is copied to `/`, `mkosi.repart/` is the disk layout), `mkosi.images/job/` the job image.
```sh
mkosi build
mkosi vm
```
`mkosi.output/` then holds the disk image, and the UKI and /usr partitions that the `os` workflow publishes as an update.
-18
View File
@@ -1,18 +0,0 @@
# git-runner job image
#
# The default image for jobs (`runs-on: linux`), built and pushed by the job
# workflow. It is kept small: just what common actions need. Jobs run their
# own podman (`docker` is an alias); the runner gives it the shared base
# images, see mkosi.extra/usr/lib/gitea-runner/config.yaml.
#
# Includes:
# - git-core openssh-clients checkout
# - nodejs26 JavaScript actions
# - podman skopeo images
# - tar gzip zstd findutils cache and artifact actions
FROM quay.io/fedora/fedora-minimal:45
RUN dnf -y install --setopt=install_weak_deps=False \
git-core nodejs26 podman skopeo tar gzip zstd findutils openssh-clients \
&& dnf clean all \
&& ln -s podman /usr/bin/docker
+6 -1
View File
@@ -1,5 +1,9 @@
# git-runner: a Fedora VM image that runs the Gitea Actions runner, built with mkosi.
# mkosi.extra/ is copied to /, mkosi.repart/ defines the disk, mkosi.prepare adds the runner.
# mkosi.extra/ is copied to /, mkosi.repart/ defines the disk, mkosi.prepare adds the runner,
# mkosi.images/job/ is the job image.
[Config]
Dependencies=job
[Distribution]
Distribution=fedora
@@ -14,6 +18,7 @@ SplitArtifacts=uki,partitions
[Content]
Bootable=yes
ExtraTrees=%O/job:/usr/lib/gitea-runner/job-image
Bootloader=systemd-boot
# - kernel-core no drivers or firmware beyond what VMs need
# - systemd-container systemd-pull, which systemd-sysupdate downloads with
-18
View File
@@ -1,18 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIC3DCCAcSgAwIBAgIUJf6brtTrJfRyg89YFBAFKNkMhZYwDQYJKoZIhvcNAQEL
BQAwJzElMCMGA1UEAwwcZ2l0LXJ1bm5lci1ta29zaSBTZWN1cmUgQm9vdDAgFw0y
NjExMTIyMTMyMzdaGA8yMTI2MTAxOTIxMzIzN1owJzElMCMGA1UEAwwcZ2l0LXJ1
bm5lci1ta29zaSBTZWN1cmUgQm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAObV42lyR2vWBjln4wLo0+l3BZY5r9ej6N19H4cGyrGyBlAmM+U8LzAG
VQYnxF+vXPfXqJtvWBl1o/10Qww+u6MD4dKrWqI00YMNEyJDTneCaobshkJf1nbK
iAZyul/nrfR8AErI52fjKrT89PdskpBsQqMeOM3Xu/q585a2aMOLQBn2TRyqq95N
KPEYfMiZRJ5QiIrWU0QdALvrxB07CZ4P0EW9chs8vyjysPM3EwiQiAny4KnAVgKF
pot8rbUcQz9ias92VlqMdTpPks7HaXyDt1eREV3yZoGPaB3kKj1DIUqHWB3B6kuk
cfmRrU34EGHfRF97Sf26BmqnE2HLIpMCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEA
ZhNuMz1p+oc0ClttIQbo4sdarpdmgr5Abvdh8C9vwVQrJLMynEQL4d4IAaSJ+SKz
og6gmNKYwmX6CusK2/vFQnobWYQphe+tiC6qdMcwMuy2R/Shp6PWTQjvsU1R7R42
Y9Uba3yFwibqRPGjFjUEh39d0MSZ5pKFuC82F746QntLZnHQQVWdnVnyTaA25JH2
F0l8CqH3iz6GHz65Q0zMx7EOVyKfAcM7t4KPH/McV8FSBCkOm9UhxGQcpnxQc8iH
JvKuI+Vys4I1xtFrCULFhR2Yo2984zafcCXlFv4Xib/h0Mpu1s8f1AcyrEsITonl
AOTjyyxDX8zSnTrW3phSjA==
-----END CERTIFICATE-----
+4 -3
View File
@@ -9,8 +9,8 @@ runner:
# podman in jobs: the job's own storage plus the shared base images (see volumes below).
CONTAINERS_STORAGE_CONF: /usr/lib/gitea-runner/job/storage.conf
labels:
# Our job image (job/Containerfile): git, node, skopeo and podman.
- "linux:docker://git.plabble.org/job79/git-runner-mkosi-job:latest"
# Our job image (mkosi.images/job), loaded from /usr at boot by gitea-runner-images.service.
- "linux:docker://localhost/git-runner-job:latest"
# Plain Fedora; our own build workflows use it, so a broken job image can't block its own fix.
- "fedora:docker://quay.io/fedora/fedora:45"
container:
@@ -25,7 +25,8 @@ container:
- /var/lib/containers/base-images:/var/lib/base-images:ro
# podman storage settings for jobs (see the file).
- /usr/lib/gitea-runner/job:/usr/lib/gitea-runner/job:ro
force_pull: true
# Images are pulled when missing: our job image never is, fedora once per boot.
force_pull: false
cache:
# Jobs reach the cache on the host through their bridge; the firewall allows this port.
host: host.containers.internal
@@ -1,8 +1,9 @@
# Pulls the base images that jobs share read-only (see /usr/lib/gitea-runner/config.yaml) before the
# runner starts, so no job uses them while they change. Hosts reboot to update, so this runs about
# as often as there are updates.
# Before the runner starts: loads our job image from /usr into podman's storage (wiped at every
# boot), and pulls the base images that jobs share read-only (see /usr/lib/gitea-runner/config.yaml),
# so no job uses them while they change. Hosts reboot to update, so this runs about as often as
# there are updates.
[Unit]
Description=Base images for Gitea Actions jobs
Description=Images for Gitea Actions jobs
Wants=network-online.target
After=network-online.target
Before=gitea-runner.service
@@ -10,8 +11,8 @@ Before=gitea-runner.service
[Service]
Type=oneshot
Environment=IMAGES=/var/lib/containers/base-images
ExecStart=/bin/sh -c 'podman tag "$(podman pull -q oci:/usr/lib/gitea-runner/job-image)" localhost/git-runner-job:latest'
# Without network the runner still starts, with the images it has.
ExecStart=-/usr/bin/podman --root ${IMAGES} --runroot /run/containers/base-images pull -q --policy newer \
quay.io/fedora/fedora:45 quay.io/fedora/fedora-minimal:45
ExecStart=-/usr/bin/podman --root ${IMAGES} --runroot /run/containers/base-images pull -q --policy newer quay.io/fedora/fedora:45
ExecStart=/usr/bin/podman --root ${IMAGES} --runroot /run/containers/base-images image prune -f
TimeoutStartSec=30min
@@ -1,13 +1,12 @@
# Updates /usr: writes the next version to the unused /usr partition.
[Transfer]
ProtectVersion=%A
# Not signed: the Secure Boot signed UKI pins the hash of /usr (usrhash=).
Verify=no
[Source]
Type=url-file
Path=https://git.plabble.org/api/packages/job79/generic/git-runner-mkosi/latest/
MatchPattern=git-runner_@v.usr-%a.raw.zst
Path=https://git.plabble.org/Job79/git-runner-mkosi/releases/download/latest/
MatchPattern=git-runner_@v.usr-%a.@u.raw.zst
[Target]
Type=partition
@@ -5,8 +5,8 @@ Verify=no
[Source]
Type=url-file
Path=https://git.plabble.org/api/packages/job79/generic/git-runner-mkosi/latest/
MatchPattern=git-runner_@v.usr-%a-verity.raw.zst
Path=https://git.plabble.org/Job79/git-runner-mkosi/releases/download/latest/
MatchPattern=git-runner_@v.usr-%a-verity.@u.raw.zst
[Target]
Type=partition
@@ -1,20 +1,17 @@
# Installs the next UKI, which systemd-boot boots by default. If it fails to boot 3 times,
# systemd-boot falls back to the previous one.
# Installs the next UKI, which systemd-boot boots by default.
[Transfer]
ProtectVersion=%A
Verify=no
[Source]
Type=url-file
Path=https://git.plabble.org/api/packages/job79/generic/git-runner-mkosi/latest/
Path=https://git.plabble.org/Job79/git-runner-mkosi/releases/download/latest/
MatchPattern=git-runner_@v.efi
[Target]
Type=regular-file
Path=/EFI/Linux
PathRelativeTo=boot
MatchPattern=git-runner_@v+@l-@d.efi git-runner_@v+@l.efi git-runner_@v.efi
MatchPattern=git-runner_@v.efi
Mode=0444
TriesLeft=3
TriesDone=0
InstancesMax=2
+25
View File
@@ -0,0 +1,25 @@
# The job image (runs-on: linux), an OCI image that the OS ships in /usr/lib/gitea-runner/job-image.
# Just what common actions need, and podman (also as docker) to build images.
#
# - dnf5 jobs can install more
# - git-core openssh-clients checkout
# - nodejs26 JavaScript actions
# - podman skopeo images
# - tar gzip zstd findutils cache and artifact actions
[Output]
Format=oci
Output=job
[Content]
Packages=
dnf5
git-core
openssh-clients
nodejs26
podman
skopeo
tar
gzip
zstd
findutils
WithDocs=no
+1
View File
@@ -0,0 +1 @@
podman
+2
View File
@@ -9,3 +9,5 @@ Verity=data
VerityMatchKey=usr
SizeMinBytes=1G
SizeMaxBytes=1G
# The file name holds the partition UUID, which usrhash= finds /usr by; updates keep it (@u in sysupdate.d).
SplitName=%t.%U
+1
View File
@@ -6,3 +6,4 @@ Verity=hash
VerityMatchKey=usr
SizeMinBytes=64M
SizeMaxBytes=64M
SplitName=%t.%U