The root filesystem (/etc and /usr) is now one read-only erofs partition behind dm-verity, updated A/B as a whole, so /etc can no longer drift from the image (stale CA certificates, frozen Fedora defaults). All state lives on a new /var partition, mounted by /etc/fstab. What used to be written to /etc at runtime: - machine ID: from the VM's firmware UUID (systemd.machine_id=firmware); /etc/machine-id is empty, so no boot counts as the first. - root password: gitea-runner-setup writes a shadow file to /var/lib/shadow, which etc-shadow.mount puts over /etc/shadow. - hostname and runner.env: runner.env moves to /var/lib/gitea-runner and holds the runner's name; gitea-runner.service sets it as the (transient) hostname, and DHCP no longer does. Hosts installed before this change must be reinstalled: updates can't change the partition layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V27snrGfdvwU7pMNBiDpHv
59 lines
2.8 KiB
YAML
59 lines
2.8 KiB
YAML
# git-runner OS image
|
|
#
|
|
# 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).
|
|
name: os
|
|
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:
|
|
os:
|
|
runs-on: fedora
|
|
env:
|
|
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
|
|
run: mkosi build
|
|
- name: Compress
|
|
working-directory: mkosi.output
|
|
run: |
|
|
zstd -q --rm -T0 -19 git-runner_*.root-*.raw
|
|
sha256sum git-runner_*.efi git-runner_*.root-*.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 -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 -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
|
|
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"
|