aboutsummaryrefslogtreecommitdiffstats
path: root/.forgejo
diff options
context:
space:
mode:
Diffstat (limited to '.forgejo')
-rw-r--r--.forgejo/workflows/build-epubs.yml54
1 files changed, 54 insertions, 0 deletions
diff --git a/.forgejo/workflows/build-epubs.yml b/.forgejo/workflows/build-epubs.yml
new file mode 100644
index 0000000..676d3c2
--- /dev/null
+++ b/.forgejo/workflows/build-epubs.yml
@@ -0,0 +1,54 @@
+name: build-epubs
+
+on:
+ schedule:
+ - cron: "0 6 * * *" # daily, to catch master/new releases
+ push:
+ branches: [main]
+ workflow_dispatch:
+
+jobs:
+ build:
+ runs-on: docker
+ container:
+ image: docker.io/debian:trixie-slim
+ steps:
+ - name: Install prerequisites
+ run: |
+ apt-get update
+ apt-get install -y --no-install-recommends ca-certificates curl xz-utils git
+
+ - uses: actions/checkout@v4
+
+ - name: Install Zig 0.15.2
+ run: |
+ set -eux
+ arch="$(uname -m)"
+ tarball="zig-${arch}-linux-0.15.2.tar.xz"
+ curl -fSL "https://ziglang.org/download/0.15.2/${tarball}" -o /tmp/zig.tar.xz
+ mkdir -p /opt/zig
+ tar -xJf /tmp/zig.tar.xz -C /opt/zig --strip-components=1
+ echo "/opt/zig" >> "$GITHUB_PATH"
+
+ - name: Build EPUBs
+ run: zig build run
+
+ - name: Commit updated EPUBs
+ run: |
+ set -eux
+ git config user.name "ziggy"
+ git config user.email "ziggy@noreply.codeberg.org"
+ git add epubs/
+ if git diff --cached --quiet; then
+ echo "No EPUB changes."
+ exit 0
+ fi
+ git commit -m "build: update epubs [skip ci]"
+ # Uses the runner token by default; set CI_PUSH_TOKEN if it lacks push rights.
+ if [ -n "${CI_PUSH_TOKEN:-}" ]; then
+ git push "https://x-access-token:${CI_PUSH_TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git" HEAD:main
+ else
+ git push origin HEAD:main
+ fi
+ env:
+ CI_PUSH_TOKEN: ${{ secrets.CI_PUSH_TOKEN }}