# git-runner OS image # # Builds the OS image, with the job image inside, and publishes it as a release of this repository. # Runners fetch their updates from releases/download/latest/ (mkosi.extra/usr/lib/sysupdate.d), # which Gitea serves from the newest release. Runs on every push, weekly for Fedora updates, and # by hand. 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 }} 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 qemu-img convert -c -O qcow2 "$(basename git-runner_*.efi .efi).raw" git-runner.qcow2 sha256sum git-runner_*.efi git-runner_*.root-*.raw.zst > SHA256SUMS # A draft until its files are uploaded, so "latest" never points at a release without them. # Then removes all but the newest 3 releases. - name: Publish working-directory: mkosi.output run: | version=$(basename git-runner_*.efi .efi) version=${version#git-runner_} id=$(curl -fsS -H "$AUTH" -H 'Content-Type: application/json' "$API/releases" \ -d "{\"tag_name\": \"$version\", \"target_commitish\": \"$GITHUB_SHA\", \"draft\": true}" | jq .id) for f in $(awk '{print $2}' SHA256SUMS) git-runner.qcow2 SHA256SUMS; do curl -fsS -o /dev/null -H "$AUTH" -F "attachment=@$f" "$API/releases/$id/assets?name=$f" done curl -fsS -o /dev/null -H "$AUTH" -H 'Content-Type: application/json' -X PATCH "$API/releases/$id" -d '{"draft": false}' curl -fsS -H "$AUTH" "$API/releases" | jq -r '.[3:][].tag_name' | while read -r tag; do curl -fsS -H "$AUTH" -X DELETE "$API/releases/tags/$tag" && curl -fsS -H "$AUTH" -X DELETE "$API/tags/$tag" done