From 9e14ad89f455ceb6377e1482b53e8da72d64e8bf Mon Sep 17 00:00:00 2001
From: poli0981
Date: Tue, 24 Nov 2026 00:31:44 +0700
Subject: [PATCH 01/25] ci: move the workflows to .gitea/workflows
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Gitea Actions reads .gitea/workflows first (runbook §3.2 item 1). The files move
unchanged here; the changes each one needs follow in their own commits. The issue
forms and the PR template stay under .github/, which Gitea also reads.
Co-Authored-By: Claude Opus 5.5
---
{.github => .gitea}/workflows/ci.yml | 0
{.github => .gitea}/workflows/content-bump.yml | 0
{.github => .gitea}/workflows/lighthouse.yml | 0
{.github => .gitea}/workflows/osv-scanner.yml | 0
{.github => .gitea}/workflows/qodana.yml | 0
{.github => .gitea}/workflows/triage.yml | 0
6 files changed, 0 insertions(+), 0 deletions(-)
rename {.github => .gitea}/workflows/ci.yml (100%)
rename {.github => .gitea}/workflows/content-bump.yml (100%)
rename {.github => .gitea}/workflows/lighthouse.yml (100%)
rename {.github => .gitea}/workflows/osv-scanner.yml (100%)
rename {.github => .gitea}/workflows/qodana.yml (100%)
rename {.github => .gitea}/workflows/triage.yml (100%)
diff --git a/.github/workflows/ci.yml b/.gitea/workflows/ci.yml
similarity index 100%
rename from .github/workflows/ci.yml
rename to .gitea/workflows/ci.yml
diff --git a/.github/workflows/content-bump.yml b/.gitea/workflows/content-bump.yml
similarity index 100%
rename from .github/workflows/content-bump.yml
rename to .gitea/workflows/content-bump.yml
diff --git a/.github/workflows/lighthouse.yml b/.gitea/workflows/lighthouse.yml
similarity index 100%
rename from .github/workflows/lighthouse.yml
rename to .gitea/workflows/lighthouse.yml
diff --git a/.github/workflows/osv-scanner.yml b/.gitea/workflows/osv-scanner.yml
similarity index 100%
rename from .github/workflows/osv-scanner.yml
rename to .gitea/workflows/osv-scanner.yml
diff --git a/.github/workflows/qodana.yml b/.gitea/workflows/qodana.yml
similarity index 100%
rename from .github/workflows/qodana.yml
rename to .gitea/workflows/qodana.yml
diff --git a/.github/workflows/triage.yml b/.gitea/workflows/triage.yml
similarity index 100%
rename from .github/workflows/triage.yml
rename to .gitea/workflows/triage.yml
--
2.54.1
From 7db93e2b3b2c333dc23605d92d8bae312c05b2fa Mon Sep 17 00:00:00 2001
From: poli0981
Date: Tue, 24 Nov 2026 00:31:57 +0700
Subject: [PATCH 02/25] ci: remove the maintenance-mode triage, which needs
GitHub
triage.yml ran on GitHub's issue and pull_request_target events with
actions/github-script. On Gitea outsiders cannot open issues or PRs (registration is
off), and the GitLab mirror's issues never reach Gitea Actions, so the bot has
nothing to watch. Decision D2 of the migration: the workflow and its script go;
the policy stays in CONTRIBUTING.md, and out-of-scope requests on the mirror are
closed by hand.
Co-Authored-By: Claude Opus 5.5
---
.gitea/workflows/triage.yml | 83 -------------------------------------
scripts/triage.mjs | 76 ---------------------------------
tests/triage.test.ts | 73 --------------------------------
3 files changed, 232 deletions(-)
delete mode 100644 .gitea/workflows/triage.yml
delete mode 100644 scripts/triage.mjs
delete mode 100644 tests/triage.test.ts
diff --git a/.gitea/workflows/triage.yml b/.gitea/workflows/triage.yml
deleted file mode 100644
index 455e39e..0000000
--- a/.gitea/workflows/triage.yml
+++ /dev/null
@@ -1,83 +0,0 @@
-name: Triage
-
-# Maintenance mode (CONTRIBUTING.md): an issue or pull request asking for a new feature is
-# labelled `enhancement` + `out-of-scope`, answered in both languages and closed. The rules
-# live in scripts/triage.mjs (unit-tested); this only wires them to GitHub. The owner's own
-# items, bots, and anything labelled `maintenance-exception` are left alone.
-#
-# pull_request_target runs with this repository's token, so it must never run a pull
-# request's code. Nothing is checked out at all: the script reads scripts/triage.mjs from the
-# default branch through the API and imports it from memory.
-on:
- issues:
- types: [opened, reopened, edited, labeled]
- pull_request_target:
- types: [opened, reopened, edited, labeled]
- # Dry run on main: classify a title and print the decision, writing nothing.
- workflow_dispatch:
- inputs:
- title:
- description: "Title to classify"
- required: true
- kind:
- description: "issue or pull_request"
- default: issue
-
-permissions: {}
-
-concurrency:
- group: triage-${{ github.event.issue.number || github.event.pull_request.number || github.run_id }}
- cancel-in-progress: false
-
-jobs:
- triage:
- runs-on: ubuntu-latest
- timeout-minutes: 5
- permissions:
- contents: read
- issues: write
- pull-requests: write
- steps:
- - name: Label and close feature requests
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
- with:
- script: |
- const { data: file } = await github.rest.repos.getContent({
- ...context.repo,
- path: "scripts/triage.mjs",
- ref: context.payload.repository.default_branch,
- });
- const source = file.content.replaceAll("\n", "");
- const { decide, closingComment, LABELS } = await import(
- `data:text/javascript;base64,${source}`
- );
-
- if (context.eventName === "workflow_dispatch") {
- const { title, kind } = context.payload.inputs;
- const verdict = decide({ title, labels: [], author: "someone", association: "NONE" });
- core.notice(`${kind} "${title}": ${verdict.action} (${verdict.reason})`);
- return;
- }
-
- const item = context.payload.issue ?? context.payload.pull_request;
- const kind = context.payload.pull_request ? "pull_request" : "issue";
- const verdict = decide({
- title: item.title,
- labels: (item.labels ?? []).map((label) => label.name),
- author: item.user.login,
- association: item.author_association,
- sender: context.payload.sender?.login,
- owner: context.repo.owner,
- state: item.state,
- });
- core.info(`#${item.number}: ${verdict.action} (${verdict.reason})`);
- if (verdict.action !== "close") return;
-
- const target = { ...context.repo, issue_number: item.number };
- await github.rest.issues.addLabels({ ...target, labels: [LABELS.feature, LABELS.closed] });
- await github.rest.issues.createComment({ ...target, body: closingComment(kind) });
- if (kind === "pull_request") {
- await github.rest.pulls.update({ ...context.repo, pull_number: item.number, state: "closed" });
- } else {
- await github.rest.issues.update({ ...target, state: "closed", state_reason: "not_planned" });
- }
diff --git a/scripts/triage.mjs b/scripts/triage.mjs
deleted file mode 100644
index 8465ecc..0000000
--- a/scripts/triage.mjs
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Maintenance-mode triage (CONTRIBUTING.md): an issue or pull request that asks for a new
- * feature is labelled and closed with an explanation; everything else is left for the owner.
- * .github/workflows/triage.yml reads this file from the default branch through the API and runs
- * it in actions/github-script: nothing is checked out, so no pull request's code ever runs.
- *
- * Deliberately narrow: only clear signals count (the title, or a label the reporter could not
- * set by accident). A bug report that happens to say "add" is not a feature request.
- */
-
-export const LABELS = {
- /** Marks a feature request (GitHub's default label, reused). */
- feature: "enhancement",
- /** Closed because new features are out of scope while the project is in maintenance mode. */
- closed: "out-of-scope",
- /** The owner's exception: the bot leaves the item alone. */
- exception: "maintenance-exception",
-};
-
-// Tested against the trimmed title. Each pattern is linear: no two quantifiers compete for the
-// same characters.
-const FEATURE_TITLES = [
- /^feat(\([^)]*\))?!?:/i, // conventional commits: "feat: …", "feat(ui)!: …"
- /^\[(feat|feature|features|enhancement|request|idea|tính năng|đề xuất)\b/iu,
- /\bfeature[\s-]+request\b/i,
- /\b(new|add|adding)(\s+a)?\s+feature\b/i,
- /(đề xuất|yêu cầu|thêm|bổ sung)\s+tính năng|tính năng mới/iu,
-];
-
-/** People whose items are never closed: the owner and collaborators, and bots. */
-const TRUSTED = new Set(["OWNER", "MEMBER", "COLLABORATOR"]);
-
-/**
- * What to do with one issue or pull request.
- *
- * @param {{ title: string, labels: string[], author: string, association?: string,
- * sender?: string, owner?: string, state?: string }} item
- * `association` is the author's (GitHub's author_association); `sender` is whoever
- * triggered the event, so the owner reopening or relabelling an item is never undone.
- * @returns {{ action: "close" | "none", reason: string }}
- */
-export function decide(item) {
- const labels = item.labels.map((label) => label.toLowerCase());
- if (item.state && item.state !== "open") return { action: "none", reason: "not open" };
- if (labels.includes(LABELS.exception)) return { action: "none", reason: "owner's exception" };
- if (TRUSTED.has(item.association ?? "")) return { action: "none", reason: "trusted author" };
- if (item.author.endsWith("[bot]")) return { action: "none", reason: "bot" };
- if (item.sender && item.owner && item.sender === item.owner) {
- return { action: "none", reason: "the owner acted on it" };
- }
- if (labels.includes(LABELS.feature)) return { action: "close", reason: "labelled as a feature" };
- const title = item.title.trim();
- if (FEATURE_TITLES.some((pattern) => pattern.test(title))) {
- return { action: "close", reason: "the title asks for a feature" };
- }
- return { action: "none", reason: "not a feature request" };
-}
-
-/** The comment left on a closed item, in both of the project's languages. */
-export function closingComment(kind) {
- const what = kind === "pull_request" ? "pull request" : "issue";
- return [
- "**Vietnamese / Tiếng Việt** — Cảm ơn bạn! Dự án đang ở **chế độ bảo trì**: không nhận tính năng",
- "mới. Repo chỉ nhận cập nhật dependency, vá bảo mật, nâng cấp runtime/framework, sửa lỗi (kể",
- "cả UI/UX và accessibility) và sửa lỗi ngôn ngữ. Vì vậy mục này được đóng tự động. Nếu bạn",
- "nghĩ đây là lỗi chứ không phải tính năng mới, hãy trả lời bên dưới — chủ repo sẽ xem lại.",
- "",
- `**English** — Thank you! This project is in **maintenance mode** and does not take new`,
- `features. It accepts dependency updates, security fixes, runtime/framework upgrades, bug fixes`,
- `(including UI/UX and accessibility) and language fixes, so this ${what} was closed`,
- `automatically. If you think it is a bug rather than a new feature, reply below and the owner`,
- `will take another look.`,
- "",
- "→ [CONTRIBUTING.md](https://github.com/poli0981/poli0981-dev/blob/main/CONTRIBUTING.md)",
- ].join("\n");
-}
diff --git a/tests/triage.test.ts b/tests/triage.test.ts
deleted file mode 100644
index f46d369..0000000
--- a/tests/triage.test.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-// Maintenance-mode triage (scripts/triage.mjs): which issues and pull requests the bot closes
-// as feature requests, and which it must leave alone.
-import assert from "node:assert/strict";
-import { describe, it } from "node:test";
-import { closingComment, decide, LABELS } from "../scripts/triage.mjs";
-
-const outsider = { labels: [] as string[], author: "someone", association: "NONE" };
-
-describe("triage", () => {
- it("closes clear feature requests, in either language", () => {
- for (const title of [
- "feat: dark mode for the admin",
- "feat(ui)!: new home page",
- "[Feature] Comments under posts",
- "[đề xuất] thêm trang tìm kiếm nâng cao",
- "Feature request: RSS for the gallery",
- "Add a feature to export posts",
- "Đề xuất tính năng: chế độ đọc to",
- "Thêm tính năng bình luận",
- "Tính năng mới: newsletter",
- ]) {
- assert.equal(decide({ ...outsider, title }).action, "close", title);
- }
- assert.equal(
- decide({ ...outsider, title: "Comments please", labels: ["Enhancement"] }).action,
- "close",
- );
- });
-
- it("leaves bugs, fixes and questions alone, even when they say 'add'", () => {
- for (const title of [
- "[web-report] Menu does not close on iPhone",
- "[a11y] Focus lost after closing the viewer",
- "fix: wrong date on the now page",
- "Typo in the privacy policy (vi)",
- "Please add alt text to the gallery cover",
- "How do I run the site locally?",
- "Lỗi chính tả trong trang giới thiệu",
- ]) {
- assert.equal(decide({ ...outsider, title }).action, "none", title);
- }
- });
-
- it("never closes the owner's items, bots, exceptions, or anything already closed", () => {
- const title = "feat: something new";
- assert.equal(decide({ ...outsider, title, association: "OWNER" }).reason, "trusted author");
- assert.equal(decide({ ...outsider, title, author: "dependabot[bot]" }).reason, "bot");
- assert.equal(
- decide({ ...outsider, title, labels: ["maintenance-exception"] }).reason,
- "owner's exception",
- );
- assert.equal(
- decide({ ...outsider, title, sender: "poli0981", owner: "poli0981" }).reason,
- "the owner acted on it",
- );
- assert.equal(decide({ ...outsider, title, state: "closed" }).reason, "not open");
- assert.equal(decide({ ...outsider, title, state: "open" }).action, "close");
- });
-
- it("explains itself in Vietnamese and English and links the policy", () => {
- const issue = closingComment("issue");
- assert.match(issue, /chế độ bảo trì/);
- assert.match(issue, /maintenance mode/);
- assert.match(issue, /this issue was closed/);
- assert.match(closingComment("pull_request"), /this pull request was closed/);
- assert.match(issue, /CONTRIBUTING\.md/);
- assert.deepEqual(Object.values(LABELS), [
- "enhancement",
- "out-of-scope",
- "maintenance-exception",
- ]);
- });
-});
--
2.54.1
From 7c1bb3efeaf17e9a24dfca5746d443bc98d0ec1d Mon Sep 17 00:00:00 2001
From: poli0981
Date: Tue, 24 Nov 2026 00:32:47 +0700
Subject: [PATCH 03/25] ci: drop SonarQube Cloud, as the migration's decision
D1 says
The maintainer removed SonarQube Cloud from every repository (D1): the sonarcloud job,
sonar-project.properties, and the coverage upload that existed only to feed it. The
unit tests still enforce 80% line coverage in the build job. Qodana and the ops
repo's Opengrep cover the analysis. The docs follow in their own commit.
Co-Authored-By: Claude Opus 5.5
---
.gitea/workflows/ci.yml | 47 +---------------------------------------
sonar-project.properties | 36 ------------------------------
2 files changed, 1 insertion(+), 82 deletions(-)
delete mode 100644 sonar-project.properties
diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml
index af13bab..82748e8 100644
--- a/.gitea/workflows/ci.yml
+++ b/.gitea/workflows/ci.yml
@@ -89,8 +89,7 @@ jobs:
- name: Dead code
run: npm run knip
- # node:test + V8 coverage. Fails under 80% lines; writes coverage/lcov.info for the
- # SonarCloud job below.
+ # node:test + V8 coverage. Fails under 80% lines.
- name: Unit tests (coverage)
run: npm run test:coverage
@@ -145,52 +144,8 @@ jobs:
if: failure()
run: tail -n 100 "$RUNNER_TEMP/preview.log" || true
- - name: Upload coverage
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
- with:
- name: coverage
- path: coverage/lcov.info
- retention-days: 7
- if-no-files-found: error
-
# Deployment is Cloudflare Workers Builds (connected to this repo), not GitHub
# Actions — this workflow is CI gates only. Workers Builds settings (docs 07): deploy
# command `npx wrangler deploy` on main, version command `npx wrangler versions upload`
# on every other branch. Plain `wrangler` finds the generated config on its own: the
# build writes .wrangler/deploy/config.json pointing at dist/server/wrangler.json.
-
- # The SonarCloud analysis (automatic analysis is switched off; this is the only one).
- # Needs SONAR_TOKEN, which Dependabot runs and forks never get, so those skip it, as do
- # the content/bump dispatches (content only, no code to analyze).
- sonarcloud:
- needs: build
- if: >-
- github.event_name == 'push' ||
- (github.event_name == 'pull_request' &&
- github.event.pull_request.head.repo.full_name == github.repository &&
- github.actor != 'dependabot[bot]')
- runs-on: ubuntu-latest
- timeout-minutes: 15
- permissions:
- contents: read
- pull-requests: read
- steps:
- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- fetch-depth: 0 # blame data and new-code detection need the whole history
-
- - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
- with:
- name: coverage
- path: coverage
-
- # Settings live in sonar-project.properties. On pull requests the job waits for the
- # quality gate and fails with it, so a red gate is visible on the PR; on main it only
- # reports (the gate there is a trend, not a merge decision).
- - name: SonarCloud scan
- uses: SonarSource/sonarqube-scan-action@59202af334b4ba7b5db01b701b8e79f8b3bef0f4 # v8.5.0
- env:
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- with:
- args: >-
- ${{ github.event_name == 'pull_request' && '-Dsonar.qualitygate.wait=true -Dsonar.qualitygate.timeout=300' || '' }}
diff --git a/sonar-project.properties b/sonar-project.properties
deleted file mode 100644
index ef6adef..0000000
--- a/sonar-project.properties
+++ /dev/null
@@ -1,36 +0,0 @@
-# SonarCloud analysis, run by the `sonarcloud` job in .github/workflows/ci.yml
-# (automatic analysis is switched off — this file is the whole configuration).
-sonar.organization=poli0981
-sonar.projectKey=poli0981_poli0981-dev
-sonar.projectName=poli0981-dev
-# Bumped with each release tag; "previous version" new-code periods start from it.
-sonar.projectVersion=2.3.0
-sonar.sourceEncoding=UTF-8
-
-# .github is analyzed too: the workflow rules (pinned actions, no npx/install scripts) are
-# part of the supply-chain posture, not noise to exclude.
-sonar.sources=src,workers/widgets/src,scripts,public,.github
-sonar.tests=tests
-# *.spec.ts is the browser-driven accessibility suite (tests/a11y, `npm run test:a11y`).
-sonar.test.inclusions=tests/**/*.test.ts,tests/**/*.spec.ts
-
-# Not ours or not code: the content submodule (Markdown), photos, generated declaration
-# files and the prebuilt search bundle.
-sonar.exclusions=src/content/**,src/assets/**,**/*.d.ts,public/pagefind/**
-
-# Coverage comes from `npm run test:coverage` (node:test + V8 → lcov), uploaded by the
-# build job. What it does not measure, and why:
-# - scripts/** build tooling: it runs in CI as part of the build itself (gen-og,
-# check-csp-hashes, gen-notices) and in the smoke test;
-# - public/** browser-only scripts (service worker, gate client, offline mini-game);
-# - src/lib/easter.ts the DOM-only console easter egg;
-# - src/content.config.ts schema declarations, exercised by every build;
-# - config files.
-# .astro and .svelte files are not analyzed by SonarCloud at all. Keep this list in step
-# with the --test-coverage-exclude flags of `npm run test:coverage`.
-sonar.javascript.lcov.reportPaths=coverage/lcov.info
-sonar.coverage.exclusions=scripts/**,public/**,.github/**,src/lib/easter.ts,src/content.config.ts,**/*.config.js,**/*.config.mjs
-
-# The vi/en dictionaries and the link table are parallel DATA by design (the same keys in
-# each locale), not duplicated logic.
-sonar.cpd.exclusions=src/i18n/vi.ts,src/i18n/en.ts,src/lib/links.ts
--
2.54.1
From 407390c2f92cdd578450c31f0f96ac95b341b0fc Mon Sep 17 00:00:00 2001
From: poli0981
Date: Tue, 24 Nov 2026 00:34:03 +0700
Subject: [PATCH 04/25] ci: Chrome and artifacts on the Gitea runner's image
GitHub's ubuntu image shipped Google Chrome, nginx and a sudo user; the Gitea runner's
image (docker.gitea.com/runner-images) has neither browser nor nginx, and its job
container runs as root.
- ci.yml: the accessibility tests take Playwright's Chromium at the lockfile's version
(A11Y_CHANNEL=bundled), cached per Playwright version, when the image has no Chrome.
- lighthouse.yml: the same Chromium through CHROME_PATH, --no-sandbox for root
(lighthouserc.json), nginx installed when missing, and the reports uploaded with
christopherhx/gitea-upload-artifact: the action's own upload uses GitHub's artifact
service, which refuses other servers.
Co-Authored-By: Claude Opus 5.5
---
.gitea/workflows/ci.yml | 46 +++++++++++++++++++++++++++---
.gitea/workflows/lighthouse.yml | 50 +++++++++++++++++++++++++++------
lighthouserc.json | 3 +-
3 files changed, 85 insertions(+), 14 deletions(-)
diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml
index 82748e8..12d659e 100644
--- a/.gitea/workflows/ci.yml
+++ b/.gitea/workflows/ci.yml
@@ -122,10 +122,48 @@ jobs:
run: npm run smoke
# Accessibility gate (ACCESSIBILITY.md). The same build is served by `astro preview`
- # (workerd, real bindings, no bot gate without its secrets) and driven with the
- # runner's own Chrome — Playwright downloads no browser. axe-core scans every page in
- # the sitemap and the dialogs while open; the keyboard, reflow and forced-colours
- # checks follow. Runs inside this job because `build` is the required status check.
+ # (workerd, real bindings, no bot gate without its secrets) and driven by Chrome.
+ # axe-core scans every page in the sitemap and the dialogs while open; the keyboard,
+ # reflow and forced-colours checks follow. Runs inside this job because `build` is
+ # the required status check.
+ #
+ # GitHub's ubuntu image shipped Google Chrome; the Gitea runner's image
+ # (docker.gitea.com/runner-images) has none, so the job takes Playwright's own
+ # Chromium at the version the lockfile pins (A11Y_CHANNEL=bundled, tests/a11y/
+ # support.ts), cached per Playwright version. An image that has Chrome keeps using it.
+ # The job container runs as root; Playwright starts Chromium without its sandbox by
+ # default (chromiumSandbox: false), which is what a root user needs.
+ - name: Which Chrome
+ id: chrome
+ run: |
+ if [ -x /usr/bin/google-chrome ]; then
+ echo "system=true" >> "$GITHUB_OUTPUT"
+ else
+ echo "system=false" >> "$GITHUB_OUTPUT"
+ echo "playwright=$(node -p "require('playwright/package.json').version")" >> "$GITHUB_OUTPUT"
+ fi
+
+ - name: Cache Playwright's Chromium
+ id: pw-cache
+ if: steps.chrome.outputs.system != 'true'
+ uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: ~/.cache/ms-playwright
+ key: playwright-chromium-${{ runner.os }}-${{ steps.chrome.outputs.playwright }}
+
+ # A cache hit restores the browser, not the system libraries it links.
+ - name: Playwright's Chromium
+ if: steps.chrome.outputs.system != 'true'
+ env:
+ CACHE_HIT: ${{ steps.pw-cache.outputs.cache-hit }}
+ run: |
+ if [ "$CACHE_HIT" = "true" ]; then
+ npx playwright install-deps chromium
+ else
+ npx playwright install --with-deps chromium
+ fi
+ echo "A11Y_CHANNEL=bundled" >> "$GITHUB_ENV"
+
- name: Start preview server
run: |
npm run preview > "$RUNNER_TEMP/preview.log" 2>&1 &
diff --git a/.gitea/workflows/lighthouse.yml b/.gitea/workflows/lighthouse.yml
index 6eb3921..a466123 100644
--- a/.gitea/workflows/lighthouse.yml
+++ b/.gitea/workflows/lighthouse.yml
@@ -51,11 +51,18 @@ jobs:
run: npm run preview &
# Cloudflare's edge compresses every text response in production; the preview does not.
- # Lighthouse measures through nginx (preinstalled on the runner, gzip — a little larger
- # than the edge's brotli) so its simulated phone downloads about the bytes a real one
- # would (home HTML 108 KB raw, 25–30 KB compressed), not three to four times as many.
+ # Lighthouse measures through nginx (gzip — a little larger than the edge's brotli) so
+ # its simulated phone downloads about the bytes a real one would (home HTML 108 KB raw,
+ # 25–30 KB compressed), not three to four times as many. GitHub's image had nginx and a
+ # user with sudo; the Gitea runner's job container runs as root and has no nginx, so it
+ # is installed here.
- name: Start compressing proxy
run: |
+ SUDO=""; [ "$(id -u)" -ne 0 ] && SUDO=sudo
+ if ! command -v nginx >/dev/null; then
+ $SUDO apt-get update -qq
+ $SUDO apt-get install -y -qq --no-install-recommends nginx
+ fi
cat > "$RUNNER_TEMP/nginx.conf" <<'EOF'
events {}
http {
@@ -76,8 +83,8 @@ jobs:
}
}
EOF
- sudo nginx -t -c "$RUNNER_TEMP/nginx.conf"
- sudo nginx -c "$RUNNER_TEMP/nginx.conf"
+ $SUDO nginx -t -c "$RUNNER_TEMP/nginx.conf"
+ $SUDO nginx -c "$RUNNER_TEMP/nginx.conf"
- name: Wait for the server
run: |
@@ -89,10 +96,25 @@ jobs:
done
echo "preview server never came up"; exit 1
+ # GitHub's image shipped Google Chrome; the Gitea runner's image has none, so Lighthouse
+ # gets Playwright's Chromium at the version the lockfile pins (CHROME_PATH is what
+ # chrome-launcher reads). The job runs as root, where Chrome refuses to start with its
+ # sandbox on: lighthouserc.json passes --no-sandbox (the pages are this build, on
+ # localhost).
+ - name: Chrome for Lighthouse
+ run: |
+ if [ -x /usr/bin/google-chrome ]; then
+ echo "CHROME_PATH=/usr/bin/google-chrome" >> "$GITHUB_ENV"
+ else
+ npx playwright install --with-deps chromium
+ echo "CHROME_PATH=$(node -p "require('playwright').chromium.executablePath()")" >> "$GITHUB_ENV"
+ fi
+
# Four representative pages (docs 14 §3): home, a blog post, a story chapter, a
# gallery album — the heaviest template of each kind. The action bundles @lhci/cli,
- # so nothing is downloaded with npx at run time; it collects, asserts against
- # lighthouserc.json (warn-only) and uploads the reports even when an assertion warns.
+ # so nothing is downloaded with npx at run time; it collects and asserts against
+ # lighthouserc.json (warn-only). Its own artifact upload uses GitHub's artifact
+ # service, which refuses other servers: the reports go up in the next step instead.
- name: Lighthouse
uses: treosh/lighthouse-ci-action@3e7e23fb74242897f95c0ba9cabad3d0227b9b18 # 12.6.2
with:
@@ -102,5 +124,15 @@ jobs:
http://127.0.0.1:4322/blog/lan-dau-viet-truyen/
http://127.0.0.1:4322/truyen/dem-khong-tieng/chuong-01/
http://127.0.0.1:4322/gallery/game/
- uploadArtifacts: true
- artifactName: lighthouse-reports
+ uploadArtifacts: false
+
+ # The reports, kept even when an assertion warns. An upload never decides the job.
+ - name: Keep the reports
+ if: ${{ !cancelled() }}
+ continue-on-error: true
+ uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
+ with:
+ name: lighthouse-reports
+ path: .lighthouseci/
+ if-no-files-found: ignore
+ retention-days: 14
diff --git a/lighthouserc.json b/lighthouserc.json
index 5de07d6..8ea1938 100644
--- a/lighthouserc.json
+++ b/lighthouserc.json
@@ -3,7 +3,8 @@
"collect": {
"numberOfRuns": 3,
"settings": {
- "throttlingMethod": "simulate"
+ "throttlingMethod": "simulate",
+ "chromeFlags": "--no-sandbox"
}
},
"assert": {
--
2.54.1
From bb03c4e9caf9376102e97f5736bb0f9cea835d10 Mon Sep 17 00:00:00 2001
From: poli0981
Date: Tue, 24 Nov 2026 00:34:18 +0700
Subject: [PATCH 05/25] ci: the ops repo's security checks replace the OSV
workflow
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
osv-scanner.yml called Google's reusable workflow and uploaded SARIF to GitHub code
scanning, which Gitea does not have. The ops repo's security.yml (pinned to the commit
of ops v2026.11.1) runs gitleaks over the whole history, Opengrep with the JS/TS rules
and osv-scanner over package-lock.json; reports are artifacts.
Weekly on Wednesday 14:13 UTC, this repo's slot in the ops cron registry (the old
Monday 03:17 UTC run falls outside the 13:00–16:00 UTC window the runner keeps), and
on every push to main and every PR.
Co-Authored-By: Claude Opus 5.5
---
.gitea/workflows/osv-scanner.yml | 42 --------------------------------
.gitea/workflows/security.yml | 37 ++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 42 deletions(-)
delete mode 100644 .gitea/workflows/osv-scanner.yml
create mode 100644 .gitea/workflows/security.yml
diff --git a/.gitea/workflows/osv-scanner.yml b/.gitea/workflows/osv-scanner.yml
deleted file mode 100644
index aeac172..0000000
--- a/.gitea/workflows/osv-scanner.yml
+++ /dev/null
@@ -1,42 +0,0 @@
-name: OSV scan
-
-# docs 06 §6 and 08 §2 both call for a weekly dependency scan; this is it.
-# It complements the per-PR `npm audit --omit=dev --audit-level=high` gate in ci.yml:
-# audit only sees the production tree and only fails on high+, while OSV covers the
-# whole lockfile (devDependencies included) against the full OSV database.
-on:
- schedule:
- # Mondays 03:17 UTC — off the hour, where scheduled-runner contention is lowest.
- - cron: "17 3 * * 1"
- workflow_dispatch:
- # Re-run when the dependency graph itself changes, so a bad bump is caught on the PR
- # rather than up to a week later…
- pull_request:
- paths: ["package-lock.json"]
- # …and once it lands, so the Security tab reflects main straight away.
- push:
- branches: [main]
- paths: ["package-lock.json"]
-
-permissions:
- contents: read
-
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
-jobs:
- scan:
- # The repo is public, so code scanning is free: findings are uploaded as SARIF and
- # show up under Security → Code scanning, and a finding still fails the run.
- # PR runs skip the upload — Dependabot PRs get a read-only token, so the upload
- # step would fail there for a reason unrelated to the scan itself.
- uses: google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@32d3cd482bdadfb38b186c0ad1b031902d55d932 # v2.7.1
- permissions:
- actions: read
- contents: read
- security-events: write
- with:
- upload-sarif: ${{ github.event_name != 'pull_request' }}
- scan-args: |-
- --lockfile=package-lock.json
diff --git a/.gitea/workflows/security.yml b/.gitea/workflows/security.yml
new file mode 100644
index 0000000..cdf1613
--- /dev/null
+++ b/.gitea/workflows/security.yml
@@ -0,0 +1,37 @@
+# Security checks from the ops repo (poli0981/.github, runbook §3.5 item 2 and §4.3).
+#
+# secrets → gitleaks over the whole git history; fails on a finding
+# sast → Opengrep: the workflow, Dockerfile and shell rules always, plus the
+# JavaScript / TypeScript rules (`node: true`); the SARIF report is an
+# artifact, since Gitea has no code-scanning UI
+# deps → osv-scanner over package-lock.json; fails on a known vulnerability
+#
+# It replaces osv-scanner.yml (Google's reusable workflow, which uploaded SARIF to GitHub
+# code scanning): the dependency scan is the same database over the same lockfile, now
+# next to the secrets and SAST checks. ci.yml keeps its per-PR `npm audit` gate.
+#
+# The reusable workflow is pinned to the commit of the ops repo's tag. Renovate does not
+# bump this pin: the `# ops …` comment is no version it reads (runbook §3.2 item 3).
+# Move it by hand when the ops repo is tagged. No secrets: nothing here needs a token.
+name: Security
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+ schedule:
+ # Wednesdays 14:13 UTC = 21:13 Vietnam: inside the 13:00–16:00 UTC window when the
+ # runner's PC is on, on this repo's slot in the ops repo's cron registry.
+ - cron: "13 14 * * 3"
+ workflow_dispatch:
+
+# Explicit, never inherited, and granted on the job.
+permissions: {}
+
+jobs:
+ security:
+ permissions:
+ contents: read
+ uses: poli0981/.github/.gitea/workflows/security.yml@2a255e0e9a60541da5c25fb4ad5cc24bd353d543 # ops v2026.11.1
+ with:
+ node: true
--
2.54.1
From 3948377cfe55b622dd2e56cdec8cb7587706f880 Mon Sep 17 00:00:00 2001
From: poli0981
Date: Tue, 24 Nov 2026 00:34:52 +0700
Subject: [PATCH 06/25] ci(qodana): the Qodana CLI instead of the action;
findings stay an artifact
JetBrains/qodana-action relies on GitHub's APIs (annotations, PR comments, the SARIF
upload to code scanning), none of which Gitea has. The job now runs the Qodana CLI
2026.3.1 in native mode, downloaded at the version and SHA-256 the ops repo's
reusable-qodana.yml pins, after the same install and type generation as before.
Results still go to Qodana Cloud; the SARIF and HTML report become the qodana-report
artifact. Renovate's PRs skip the job, as Dependabot's did, and so does a run without
QODANA_TOKEN.
A local job rather than a caller of reusable-qodana.yml: the scan needs this repo's
generated binding types, and the ops tag callers pin predates the reusable workflow.
Co-Authored-By: Claude Opus 5.5
---
.gitea/workflows/qodana.yml | 104 +++++++++++++++++++++++++-----------
qodana.yaml | 2 +-
2 files changed, 75 insertions(+), 31 deletions(-)
diff --git a/.gitea/workflows/qodana.yml b/.gitea/workflows/qodana.yml
index 6935ef0..009d50f 100644
--- a/.gitea/workflows/qodana.yml
+++ b/.gitea/workflows/qodana.yml
@@ -1,11 +1,21 @@
name: Qodana
# JetBrains Qodana (Qodana for JS, WebStorm's inspections) over the whole repository: on every
-# PR, on main and by hand. Settings live in qodana.yaml. Results go to Qodana Cloud (the
-# project token is the QODANA_TOKEN secret) and, for main, to GitHub code scanning as SARIF.
+# PR, on main and by hand. Settings live in qodana.yaml; its failThreshold makes any finding
+# fail the scan. Results go to Qodana Cloud (the project token is the QODANA_TOKEN secret) and
+# into the `qodana-report` artifact (SARIF + HTML report): Gitea has no code-scanning UI, so
+# the SARIF upload of the GitHub days is gone.
#
-# Advisory, not required: the main ruleset requires only `build`, and Dependabot and fork PRs
-# get no secrets, so they skip this job like the SonarCloud one in ci.yml.
+# The Qodana CLI, not JetBrains/qodana-action (which relies on GitHub's APIs for annotations
+# and comments), at a pinned version, SHA-256 verified — the version and checksum the ops
+# repo's reusable-qodana.yml pins. Renovate does not update it (it is not an action): bump
+# both together, by hand. A local job rather than a caller of that reusable workflow: the
+# scan needs this repo's generated binding types first, and the ops tag callers pin
+# (v2026.11.1) predates the reusable one.
+#
+# Advisory, not required: branch protection requires only CI's `build`. Renovate's PRs skip
+# it — Gitea gives a same-repo PR the repository's secrets, and a Renovate run installs the
+# very update under review, so no token goes near it — as does a run without the token.
on:
pull_request:
push:
@@ -13,9 +23,8 @@ on:
paths-ignore: ["poli0981.dev-docs/**", "*.md", "LICENSE"]
workflow_dispatch:
-# Explicit — a missing block makes GitHub default every scope to `none`.
-permissions:
- contents: read
+# Explicit, and granted on the job.
+permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
@@ -24,28 +33,41 @@ concurrency:
jobs:
qodana:
- if: >-
- github.event_name != 'pull_request' ||
- (github.event.pull_request.head.repo.full_name == github.repository &&
- github.actor != 'dependabot[bot]')
+ name: Qodana for JS
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
- checks: write # problem annotations on the commit
- pull-requests: write # the summary comment on PRs
- security-events: write # SARIF upload (main and manual runs)
+ env:
+ QODANA_CLI_VERSION: 2026.3.1
+ QODANA_CLI_SHA256: dae6d31f481ed15c6c016fd746e907978f0c1437010326fa04a92f13c7c52338 # qodana_linux_x86_64.tar.gz
steps:
- # Pinned to commit SHAs like every other workflow here; Dependabot keeps them current.
+ - name: Check for QODANA_TOKEN
+ id: token
+ env:
+ QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
+ ACTOR: ${{ github.actor }}
+ AUTHOR: ${{ github.event.pull_request.user.login }}
+ run: |
+ if [ "$ACTOR" = renovate-bot ] || [ "$AUTHOR" = renovate-bot ]; then
+ echo "present=false" >> "$GITHUB_OUTPUT"
+ echo "::notice::Qodana skipped — a Renovate pull request installs the update under review, so no token goes near it."
+ elif [ -n "$QODANA_TOKEN" ]; then
+ echo "present=true" >> "$GITHUB_OUTPUT"
+ else
+ echo "present=false" >> "$GITHUB_OUTPUT"
+ echo "::notice::Qodana skipped — QODANA_TOKEN is not available to this run."
+ fi
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ if: steps.token.outputs.present == 'true'
with:
- # The PR's own head commit, not the merge preview, so Qodana Cloud links to it.
- ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
submodules: recursive
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
+ if: steps.token.outputs.present == 'true'
with:
node-version-file: .nvmrc
cache: npm
@@ -53,35 +75,57 @@ jobs:
# Same rules as ci.yml: no dependency lifecycle script runs in CI, and any lockfile
# package with an install script must be on package.json#allowScripts.
- name: Install
+ if: steps.token.outputs.present == 'true'
run: npm ci --ignore-scripts
- name: Install scripts allow-listed
+ if: steps.token.outputs.present == 'true'
run: npm run check-install-scripts
# Gitignored, generated types the TypeScript service needs to resolve imports of
# cloudflare:workers, astro:content and friends.
- name: Generate types
+ if: steps.token.outputs.present == 'true'
run: |
npm run types
npm run types:widgets
npm run astro -- sync
+ - name: Install the Qodana CLI ${{ env.QODANA_CLI_VERSION }}
+ if: steps.token.outputs.present == 'true'
+ run: |
+ set -euo pipefail
+ tmp="${RUNNER_TEMP:-/tmp}"
+ tgz="$tmp/qodana.tar.gz"
+ curl --proto '=https' -fsSL --retry 3 -o "$tgz" \
+ "https://github.com/JetBrains/qodana-cli/releases/download/v${QODANA_CLI_VERSION}/qodana_linux_x86_64.tar.gz"
+ echo "${QODANA_CLI_SHA256} $tgz" | sha256sum -c -
+ mkdir -p "$tmp/qodana-cli"
+ tar -xzf "$tgz" -C "$tmp/qodana-cli" qodana
+ echo "$tmp/qodana-cli" >> "$GITHUB_PATH"
+
+ # Whole repository every time (it is small), so the quality gate in qodana.yaml always
+ # judges the full picture rather than the files a PR happens to touch. Native mode
+ # (qodana.yaml: withinDocker: false): the job already is a container.
- name: Qodana scan
- uses: JetBrains/qodana-action@13e3acbbaeb2cbfc37893b98e74594985edf42eb # v2026.2.4
+ if: steps.token.outputs.present == 'true'
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
QODANA_ENDPOINT: https://qodana.cloud
- with:
- # Whole repository every time (it is small), so the quality gate in qodana.yaml
- # always judges the full picture rather than the files a PR happens to touch.
- pr-mode: false
- upload-result: true
+ run: |
+ qodana --version
+ qodana scan --within-docker false \
+ --results-dir "${RUNNER_TEMP:-/tmp}/qodana/results" \
+ --cache-dir "${RUNNER_TEMP:-/tmp}/qodana/cache"
- # Like the OSV scan: main and manual runs only, so PR runs don't open code-scanning
- # alerts for code that may never merge.
- - name: Upload SARIF to code scanning
- if: ${{ !cancelled() && github.event_name != 'pull_request' }}
- uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
+ # !cancelled(), not the implicit success(): a scan that finds something fails, and
+ # those are exactly the findings the report must keep. An upload never decides the job.
+ - name: Keep the report
+ if: ${{ !cancelled() && steps.token.outputs.present == 'true' }}
+ continue-on-error: true
+ uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
- sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
- category: qodana
+ name: qodana-report
+ path: ${{ runner.temp }}/qodana/results/
+ if-no-files-found: ignore
+ retention-days: 14
diff --git a/qodana.yaml b/qodana.yaml
index a0a7e1a..c53f87e 100644
--- a/qodana.yaml
+++ b/qodana.yaml
@@ -1,4 +1,4 @@
-# JetBrains Qodana — run by .github/workflows/qodana.yml on every PR and on main
+# JetBrains Qodana — run by .gitea/workflows/qodana.yml on every PR and on main
# (docs 08 §0). Reference: https://www.jetbrains.com/help/qodana/configuration-reference.html
#
# Qodana for JS is WebStorm's inspection engine. It reads .ts/.js/.mjs, CSS, JSON, YAML and
--
2.54.1
From b2c5062a0576f76e8761115a7f7f1999194af75b Mon Sep 17 00:00:00 2001
From: poli0981
Date: Tue, 24 Nov 2026 00:35:56 +0700
Subject: [PATCH 07/25] ci(deploy): main deploys from Gitea CI with wrangler
Cloudflare Workers Builds pulled from GitHub and stopped with it (the maintainer has
disconnected it). Decision D3 of the migration: a deploy job in ci.yml, on a push to
main or a dispatch on main, after `build` passed on the same commit. It rebuilds with
the production settings Workers Builds' build variables used to give (the public
Turnstile site key, the Web Analytics beacon), runs `wrangler deploy` with the
user-level CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID secrets, and waits until
/api/health reports the commit.
PRs and other branches get no preview versions: that would put the Cloudflare token
within reach of a PR's code. The workflow's permissions move to the jobs.
Co-Authored-By: Claude Opus 5.5
---
.gitea/workflows/ci.yml | 89 +++++++++++++++++++++++++++++++++++------
astro.config.mjs | 13 +++---
2 files changed, 84 insertions(+), 18 deletions(-)
diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml
index 12d659e..ee6601f 100644
--- a/.gitea/workflows/ci.yml
+++ b/.gitea/workflows/ci.yml
@@ -1,9 +1,12 @@
name: CI
-# PRs always run: `build` is a required status check in the main ruleset, so a
-# paths-ignore here would leave docs-only PRs waiting forever for a check that never
-# starts. Pushes to main may still skip docs-only changes. NOTE: use `*.md` (root-level)
-# — NOT `**/*.md` — because blog/story content lives at src/content/**/*.{md,mdx}.
+# PRs always run: `build` is the required status check of main's branch protection, so
+# a paths-ignore here would leave docs-only PRs waiting forever for a check that never
+# starts. Pushes to main may still skip docs-only changes — they deploy nothing either.
+# NOTE: use `*.md` (root-level) — NOT `**/*.md` — because blog/story content lives at
+# src/content/**/*.{md,mdx}.
+#
+# A push to main (and a dispatch on main) also deploys: the `deploy` job below.
on:
pull_request:
# Dispatched on content/bump by content-bump.yml (PRs opened with GITHUB_TOKEN don't
@@ -13,9 +16,9 @@ on:
branches: [main]
paths-ignore: ["poli0981.dev-docs/**", "*.md", "LICENSE"]
-# Explicit — a missing block makes GitHub default every scope to `none`.
-permissions:
- contents: read
+# Explicit, and granted per job: a grant made up here would reach every job, one added
+# later included.
+permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
@@ -182,8 +185,70 @@ jobs:
if: failure()
run: tail -n 100 "$RUNNER_TEMP/preview.log" || true
- # Deployment is Cloudflare Workers Builds (connected to this repo), not GitHub
- # Actions — this workflow is CI gates only. Workers Builds settings (docs 07): deploy
- # command `npx wrangler deploy` on main, version command `npx wrangler versions upload`
- # on every other branch. Plain `wrangler` finds the generated config on its own: the
- # build writes .wrangler/deploy/config.json pointing at dist/server/wrangler.json.
+ # Production. Cloudflare Workers Builds pulled from GitHub and stopped with it, so main
+ # deploys from here (migration decision D3): after `build` passed on the same commit,
+ # rebuild with the production settings and `wrangler deploy` at 100%. Nothing else
+ # deploys: PRs and other branches get no preview versions, which would put the Cloudflare
+ # token within reach of a PR's code (Gitea gives same-repo PRs the secrets, Renovate's
+ # included).
+ #
+ # The workflow's concurrency group keeps main runs in order and never cancels one, so two
+ # quick merges deploy one after the other, the newer last. The runner lives on the
+ # maintainer's PC: a merge made while it is off deploys when it comes back.
+ deploy:
+ needs: build
+ if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
+ runs-on: ubuntu-latest
+ timeout-minutes: 20
+ permissions:
+ contents: read
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ submodules: recursive # the content, and HEAD:src/content for /api/health
+ persist-credentials: false
+
+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
+ with:
+ node-version-file: .nvmrc
+ cache: npm
+
+ - name: Install
+ run: npm ci --ignore-scripts
+
+ # What Workers Builds' build variables did: the Turnstile site key (public — every
+ # gated page carries it) is inlined into the client, and the Cloudflare Web Analytics
+ # beacon is switched on for production builds only (astro.config.mjs). GITHUB_SHA,
+ # which Gitea sets too, becomes the commit /api/health reports.
+ - name: Build (production)
+ env:
+ PUBLIC_TURNSTILE_SITE_KEY: "0x4AAAAAAD5Cup6ayN5o78wu"
+ PUBLIC_CF_BEACON: "true"
+ run: npm run build
+
+ # Token scope (docs 07): Account → Workers Scripts: Edit, plus what the bindings
+ # need to resolve (KV, R2, routes and custom domains on the zone). User-level
+ # Actions secrets on Gitea, shared by the web repos. Plain `wrangler` finds the
+ # generated config on its own: the build writes .wrangler/deploy/config.json
+ # pointing at dist/server/wrangler.json.
+ - name: Deploy to Cloudflare Workers
+ env:
+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
+ CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
+ WRANGLER_SEND_METRICS: "false"
+ run: npx wrangler deploy --message "main ${GITHUB_SHA:0:7}"
+
+ # The deploy is live when the site says so: /api/health reports the commit of the
+ # build it runs (src/lib/version.ts).
+ - name: Live
+ run: |
+ for i in $(seq 1 30); do
+ live=$(curl -fsS https://poli0981.dev/api/health | node -e '
+ let s = ""; process.stdin.on("data", (d) => (s += d));
+ process.stdin.on("end", () => { try { console.log(JSON.parse(s).version.commit ?? ""); } catch { console.log(""); } });
+ ' || true)
+ if [ "$live" = "$GITHUB_SHA" ]; then echo "live: $live"; exit 0; fi
+ sleep 4
+ done
+ echo "::error::/api/health still reports ${live:-nothing}, not $GITHUB_SHA"
+ exit 1
diff --git a/astro.config.mjs b/astro.config.mjs
index 0956632..2083ac8 100644
--- a/astro.config.mjs
+++ b/astro.config.mjs
@@ -61,15 +61,16 @@ const localizedNotFound = {
},
};
-// Cloudflare Web Analytics beacon: only in builds made by Workers Builds for main
-// (WORKERS_CI / WORKERS_CI_BRANCH are injected there), so CI, Lighthouse and branch
-// previews never report page views. Overridable with PUBLIC_CF_BEACON=true|false.
+// Cloudflare Web Analytics beacon: only in production builds, so CI, Lighthouse and local
+// builds never report page views. The deploy job in .gitea/workflows/ci.yml sets
+// PUBLIC_CF_BEACON=true; a Workers Builds build of main (WORKERS_CI / WORKERS_CI_BRANCH,
+// before the move to Gitea) turns it on by itself.
const CF_BEACON_DEFAULT =
process.env.WORKERS_CI === "1" && process.env.WORKERS_CI_BRANCH === "main";
-// The commit a build was made from (Workers Builds sets WORKERS_CI_COMMIT_SHA, GitHub Actions
-// GITHUB_SHA). /api/health reports it next to the Worker version id (src/lib/version.ts), so
-// "what is live?" maps straight to a commit.
+// The commit a build was made from (Gitea Actions sets GITHUB_SHA, as GitHub Actions did;
+// Workers Builds set WORKERS_CI_COMMIT_SHA). /api/health reports it next to the Worker version
+// id (src/lib/version.ts), so "what is live?" maps straight to a commit.
const BUILD_COMMIT = process.env.WORKERS_CI_COMMIT_SHA ?? process.env.GITHUB_SHA ?? null;
// The poli0981/content commit this build's src/content points at: the gitlink recorded in
--
2.54.1
From 7215d59f31d5c4097f3a2c234944397c1a4ddd89 Mon Sep 17 00:00:00 2001
From: poli0981
Date: Tue, 24 Nov 2026 00:47:15 +0700
Subject: [PATCH 08/25] ci(content): the admin's publish runs on Gitea's API
content-bump.yml used `gh` to open the content/bump PR, enable GitHub's auto-merge and
dispatch CI. On Gitea the same steps are calls to Gitea's API with the job token, in
scripts/content-publish.mjs (unit-tested):
- `open` (content-bump.yml): open or update the PR, write in its body whether it
merges itself ( for Markdown/JSON,
when MDX changed, with a comment), and dispatch ci.yml on content/bump: a PR the job
token opens starts no workflow.
- `merge` (ci.yml's new publish job, after `build` passed on the dispatched run):
squash-merge the PR at the commit CI built when its body says auto, then dispatch
ci.yml on main, because the job token's merge commit starts no workflow either; that
run deploys. A refused merge fails the job and says so on the PR; merging by hand
deploys as usual.
Decision D5 named Gitea's merge_when_checks_succeed. The merge happens in CI instead:
the scheduled merge would also be the job token's push, so nothing would deploy it,
and the body marker gives the admin the "merges itself" flag Gitea's API lacks.
Co-Authored-By: Claude Opus 5.5
---
.gitea/workflows/ci.yml | 28 ++++++
.gitea/workflows/content-bump.yml | 65 ++++++-------
scripts/content-publish.mjs | 155 ++++++++++++++++++++++++++++++
tests/content-publish.test.ts | 155 ++++++++++++++++++++++++++++++
4 files changed, 370 insertions(+), 33 deletions(-)
create mode 100644 scripts/content-publish.mjs
create mode 100644 tests/content-publish.test.ts
diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml
index ee6601f..c6ae387 100644
--- a/.gitea/workflows/ci.yml
+++ b/.gitea/workflows/ci.yml
@@ -185,6 +185,34 @@ jobs:
if: failure()
run: tail -n 100 "$RUNNER_TEMP/preview.log" || true
+ # Content publish, second half (content-bump.yml is the first): when the admin's publish
+ # dispatched this run on content/bump and `build` passed, merge the content/bump PR
+ # (Markdown/JSON only — an MDX publish waits for a review) and dispatch this workflow on
+ # main, which deploys. The dispatch is needed because nothing the job token does starts a
+ # workflow, its merge commit included. If the merge is refused, the job fails and says so
+ # on the PR; a merge by hand deploys as usual.
+ publish:
+ needs: build
+ if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/content/bump'
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ permissions:
+ contents: write # the merge
+ pull-requests: write # the merge, a comment when it fails
+ actions: write # dispatch ci.yml on main
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - name: Merge the publish PR and deploy main
+ env:
+ TOKEN: ${{ github.token }}
+ API: ${{ github.api_url }}
+ REPO: ${{ github.repository }}
+ SHA: ${{ github.sha }}
+ run: node scripts/content-publish.mjs merge
+
# Production. Cloudflare Workers Builds pulled from GitHub and stopped with it, so main
# deploys from here (migration decision D3): after `build` passed on the same commit,
# rebuild with the production settings and `wrangler deploy` at 100%. Nothing else
diff --git a/.gitea/workflows/content-bump.yml b/.gitea/workflows/content-bump.yml
index 1cd6535..e54e9a0 100644
--- a/.gitea/workflows/content-bump.yml
+++ b/.gitea/workflows/content-bump.yml
@@ -1,20 +1,27 @@
name: Content publish
-# "Publish" in the admin (admin.poli0981.dev) dispatches this. It points the src/content
-# submodule at poli0981/content's main, commits that on the content/bump branch, opens
-# (or updates) a PR and, when only Markdown/JSON changed, enables auto-merge. CI then runs
-# on the bump commit; when the required `build` check passes the PR merges itself and
-# Workers Builds deploys main.
+# "Publish" in the admin (admin.poli0981.dev) dispatches this, and so does every admin save.
+# It points the src/content submodule at poli0981/content's main, commits that on the
+# content/bump branch, opens (or updates) a PR, and starts CI on the bump commit. When only
+# Markdown/JSON changed, CI's `publish` job merges the PR once `build` passed there and
+# starts the deploy of main (ci.yml).
#
-# Why a workflow: the admin's token can write ONLY the content repo (+ dispatch this). If
-# it leaked, the worst case is content edits — never code pushed to this repo. MDX runs
-# code at build time, so anything other than .md/.json waits for a human review.
+# Why a workflow: the admin's token never pushes code to this repository; the most it can
+# do here is start this workflow. MDX runs code at build time, so a publish that touches
+# anything other than .md/.json waits for a human review instead of merging itself.
+#
+# Gitea, not GitHub (migration decision D5): `gh` is gone, the PR and the CI dispatch are
+# plain calls to Gitea's API with the job token. A PR opened with the job token starts no
+# workflow, so CI is dispatched on content/bump. Whether the PR merges by itself is in its
+# body (`` or ``), where the admin reads it:
+# Gitea's API has no auto-merge field.
on:
workflow_dispatch:
-permissions:
- contents: read
+permissions: {}
+# One run at a time, never cancelled: a run waiting behind a running one reads the newest
+# content main when it starts, so quick saves in a row end in one more publish, not many.
concurrency:
group: content-bump
cancel-in-progress: false
@@ -22,10 +29,11 @@ concurrency:
jobs:
bump:
runs-on: ubuntu-latest
+ timeout-minutes: 10
permissions:
contents: write # push content/bump
- pull-requests: write # open the PR, enable auto-merge
- actions: write # run ci.yml on the bump commit
+ pull-requests: write # open or update the PR, comment on it
+ actions: write # dispatch ci.yml on the bump commit
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
@@ -55,34 +63,25 @@ jobs:
echo "EOF"
} >> "$GITHUB_OUTPUT"
- - name: Commit, open/update the PR, queue CI
+ - name: Commit and push content/bump
if: steps.bump.outputs.changed == 'true'
env:
- GH_TOKEN: ${{ github.token }}
NEW: ${{ steps.bump.outputs.new }}
- AUTO: ${{ steps.bump.outputs.auto }}
FILES: ${{ steps.bump.outputs.files }}
run: |
- git config user.name "github-actions[bot]"
- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
+ git config user.name "Content publish"
+ git config user.email "actions@noreply.git.poli0981.dev"
git switch --create content/bump
git add src/content
git commit --quiet -m "chore(content): publish ${NEW:0:7}" -m "$FILES"
git push --force --quiet origin content/bump
- if [ "$(gh pr view content/bump --json state --jq .state 2>/dev/null)" != "OPEN" ]; then
- gh pr create --base main --head content/bump \
- --title "chore(content): publish from admin" \
- --body "Bumps \`src/content\` to poli0981/content@${NEW}. Opened by the admin's **Publish** button (.github/workflows/content-bump.yml)."
- fi
-
- if [ "$AUTO" = "true" ]; then
- gh pr merge content/bump --auto --squash
- else
- gh pr merge content/bump --disable-auto 2>/dev/null || true
- gh pr comment content/bump --body "This publish touches files other than .md/.json (MDX runs code at build time), so it waits for a review instead of auto-merging."
- fi
-
- # PRs opened with GITHUB_TOKEN don't trigger pull_request workflows; a dispatch is
- # the exception, and its `build` check lands on the bump commit for the ruleset.
- gh workflow run ci.yml --ref content/bump
+ - name: Open or update the PR, queue CI
+ if: steps.bump.outputs.changed == 'true'
+ env:
+ TOKEN: ${{ github.token }}
+ API: ${{ github.api_url }}
+ REPO: ${{ github.repository }}
+ NEW: ${{ steps.bump.outputs.new }}
+ AUTO: ${{ steps.bump.outputs.auto }}
+ run: node scripts/content-publish.mjs open
diff --git a/scripts/content-publish.mjs b/scripts/content-publish.mjs
new file mode 100644
index 0000000..be56b54
--- /dev/null
+++ b/scripts/content-publish.mjs
@@ -0,0 +1,155 @@
+#!/usr/bin/env node
+// The Gitea half of a content publish (.gitea/workflows/content-bump.yml and ci.yml), with
+// the job token. Two commands:
+//
+// node scripts/content-publish.mjs open content-bump.yml, after pushing content/bump:
+// open or update the PR, say in its body whether it
+// merges itself, and dispatch ci.yml on the branch
+// node scripts/content-publish.mjs merge ci.yml's `publish` job, after `build` passed on
+// content/bump: merge the PR when its body says
+// auto, then dispatch ci.yml on main to deploy
+//
+// Environment: API (github.api_url), REPO (owner/name), TOKEN (the job token); `open` also
+// NEW (the content commit) and AUTO ("true" when only .md/.json changed); `merge` also SHA
+// (the commit CI built).
+//
+// Why the dispatches: Gitea, like GitHub, starts no workflow for what the job token does —
+// neither for the PR it opens nor for the merge commit it pushes to main.
+
+import { pathToFileURL } from "node:url";
+
+export const BRANCH = "content/bump";
+export const BASE = "main";
+export const MARK_AUTO = "";
+export const MARK_REVIEW = "";
+
+const REVIEW_NOTE =
+ "This publish touches files other than .md/.json (MDX runs code at build time), so it waits for a review instead of merging itself.";
+
+/** The PR body; its last line is the marker the admin and the merge step read. */
+export function prBody(contentCommit, auto) {
+ return [
+ `Bumps \`src/content\` to poli0981/content@${contentCommit}.`,
+ "Opened by the admin's **Publish** (`.gitea/workflows/content-bump.yml`).",
+ "",
+ auto
+ ? "Only Markdown/JSON changed: CI merges this PR once `build` passes, then deploys main."
+ : REVIEW_NOTE,
+ "",
+ auto ? MARK_AUTO : MARK_REVIEW,
+ ].join("\n");
+}
+
+export const isAuto = (body) => typeof body === "string" && body.includes(MARK_AUTO);
+
+/** A small client for Gitea's REST API with the job token. */
+export function gitea({ api, repo, token, fetch = globalThis.fetch }) {
+ return async function call(method, path, body) {
+ const res = await fetch(`${api}/repos/${repo}${path}`, {
+ method,
+ headers: {
+ authorization: `token ${token}`,
+ accept: "application/json",
+ ...(body === undefined ? {} : { "content-type": "application/json" }),
+ },
+ body: body === undefined ? undefined : JSON.stringify(body),
+ });
+ const text = await res.text();
+ if (!res.ok) {
+ const error = new Error(`${method} ${path} → ${res.status} ${text.slice(0, 300)}`);
+ error.status = res.status;
+ throw error;
+ }
+ return text ? JSON.parse(text) : null;
+ };
+}
+
+/** The open content/bump → main PR, or null. */
+export async function findPull(call) {
+ const pulls = await call("GET", "/pulls?state=open&limit=50");
+ return pulls.find((p) => p.head?.ref === BRANCH && p.base?.ref === BASE) ?? null;
+}
+
+export async function open({ call, contentCommit, auto, log = console.log }) {
+ const body = prBody(contentCommit, auto);
+ let pull = await findPull(call);
+ const wasAuto = pull ? isAuto(pull.body) : true;
+ if (pull) {
+ await call("PATCH", `/pulls/${pull.number}`, { body });
+ log(`Updated PR #${pull.number}.`);
+ } else {
+ pull = await call("POST", "/pulls", {
+ base: BASE,
+ head: BRANCH,
+ title: "chore(content): publish from admin",
+ body,
+ });
+ log(`Opened PR #${pull.number}.`);
+ }
+ // Say it once, when the PR turns from "merges itself" to "waits for a review".
+ if (!auto && wasAuto) {
+ await call("POST", `/issues/${pull.number}/comments`, { body: REVIEW_NOTE });
+ }
+ await call("POST", "/actions/workflows/ci.yml/dispatches", { ref: BRANCH });
+ log(`Dispatched ci.yml on ${BRANCH}.`);
+ return pull.number;
+}
+
+export async function merge({ call, sha, log = console.log }) {
+ const pull = await findPull(call);
+ if (!pull) {
+ log(`No open PR from ${BRANCH}: nothing to merge.`);
+ return "none";
+ }
+ if (pull.head?.sha !== sha) {
+ log(`PR #${pull.number} has moved on to ${pull.head?.sha}; its own CI run merges it.`);
+ return "moved";
+ }
+ if (!isAuto(pull.body)) {
+ log(`PR #${pull.number} touches more than .md/.json: it waits for a review.`);
+ return "review";
+ }
+ try {
+ await call("POST", `/pulls/${pull.number}/merge`, {
+ Do: "squash",
+ MergeTitleField: `${pull.title} (#${pull.number})`,
+ head_commit_id: sha,
+ delete_branch_after_merge: true,
+ });
+ } catch (error) {
+ // Leave a trail on the PR: the admin shows it as waiting, and a merge by hand still
+ // deploys (a user's push starts CI on main).
+ await call("POST", `/issues/${pull.number}/comments`, {
+ body: `CI could not merge this publish: ${error.message}\n\nMerge it by hand; the push to main deploys it.`,
+ }).catch(() => {});
+ throw error;
+ }
+ log(`Merged PR #${pull.number}.`);
+ await call("POST", "/actions/workflows/ci.yml/dispatches", { ref: BASE });
+ log(`Dispatched ci.yml on ${BASE} (deploy).`);
+ return "merged";
+}
+
+async function main(command) {
+ const { API, REPO, TOKEN } = process.env;
+ if (!API || !REPO || !TOKEN) throw new Error("API, REPO and TOKEN must be set");
+ const call = gitea({ api: API, repo: REPO, token: TOKEN });
+ if (command === "open") {
+ const { NEW, AUTO } = process.env;
+ if (!NEW) throw new Error("NEW must be set");
+ await open({ call, contentCommit: NEW, auto: AUTO === "true" });
+ } else if (command === "merge") {
+ const { SHA } = process.env;
+ if (!SHA) throw new Error("SHA must be set");
+ await merge({ call, sha: SHA });
+ } else {
+ throw new Error(`unknown command ${command ?? "(none)"}: use open or merge`);
+ }
+}
+
+if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
+ main(process.argv[2]).catch((error) => {
+ console.error(`::error::${error.message}`);
+ process.exit(1);
+ });
+}
diff --git a/tests/content-publish.test.ts b/tests/content-publish.test.ts
new file mode 100644
index 0000000..c130c91
--- /dev/null
+++ b/tests/content-publish.test.ts
@@ -0,0 +1,155 @@
+// The Gitea half of a content publish (scripts/content-publish.mjs): the PR that
+// content-bump.yml opens, and the merge + deploy dispatch that ci.yml's publish job does.
+import assert from "node:assert/strict";
+import { describe, it } from "node:test";
+import {
+ gitea,
+ isAuto,
+ MARK_AUTO,
+ MARK_REVIEW,
+ merge,
+ open,
+ prBody,
+} from "../scripts/content-publish.mjs";
+
+interface Sent {
+ method: string;
+ path: string;
+ body: unknown;
+}
+
+/** A fake Gitea for the site repo's pulls, comments and workflow dispatches. */
+function fakeGitea(pulls: Record[], refuse: Record = {}) {
+ const sent: Sent[] = [];
+ const fetch = async (url: string, init: RequestInit = {}) => {
+ const { pathname, search } = new URL(url);
+ const path = pathname.replace("/api/v1/repos/poli0981/poli0981-dev", "") + search;
+ const method = init.method ?? "GET";
+ sent.push({ method, path, body: init.body ? JSON.parse(String(init.body)) : undefined });
+ assert.equal(new Headers(init.headers).get("authorization"), "token job-token");
+ const status = refuse[`${method} ${path}`];
+ if (status) return new Response(JSON.stringify({ message: "refused" }), { status });
+ if (method === "GET" && path.startsWith("/pulls?")) return Response.json(pulls);
+ if (method === "POST" && path === "/pulls") {
+ return Response.json({ number: 7, html_url: "u" }, { status: 201 });
+ }
+ return new Response(null, { status: method === "POST" ? 201 : 200 });
+ };
+ const call = gitea({
+ api: "https://git.poli0981.dev/api/v1",
+ repo: "poli0981/poli0981-dev",
+ token: "job-token",
+ fetch: fetch as typeof globalThis.fetch,
+ });
+ return { call, sent };
+}
+
+const bumpPull = (body: string, sha = "head-sha") => ({
+ number: 5,
+ title: "chore(content): publish from admin",
+ body,
+ head: { ref: "content/bump", sha },
+ base: { ref: "main" },
+});
+const quiet = () => {};
+
+describe("content publish: the PR body", () => {
+ it("says whether CI merges it, in a marker the admin reads", () => {
+ const auto = prBody("abc123", true);
+ assert.match(auto, /poli0981\/content@abc123/);
+ assert.ok(auto.endsWith(MARK_AUTO));
+ assert.ok(isAuto(auto));
+ const review = prBody("abc123", false);
+ assert.ok(review.endsWith(MARK_REVIEW));
+ assert.match(review, /waits for a review/);
+ assert.equal(isAuto(review), false);
+ assert.equal(isAuto(null), false);
+ });
+});
+
+describe("content publish: open", () => {
+ it("opens the PR when there is none, then dispatches CI on the branch", async () => {
+ const { call, sent } = fakeGitea([{ ...bumpPull(""), head: { ref: "other", sha: "x" } }]);
+ assert.equal(await open({ call, contentCommit: "abc", auto: true, log: quiet }), 7);
+ assert.deepEqual(
+ sent.map((s) => `${s.method} ${s.path}`),
+ [
+ "GET /pulls?state=open&limit=50",
+ "POST /pulls",
+ "POST /actions/workflows/ci.yml/dispatches",
+ ],
+ );
+ assert.deepEqual(sent[1].body, {
+ base: "main",
+ head: "content/bump",
+ title: "chore(content): publish from admin",
+ body: prBody("abc", true),
+ });
+ assert.deepEqual(sent[2].body, { ref: "content/bump" });
+ });
+
+ it("updates an open PR, and comments once when it turns to review", async () => {
+ const { call, sent } = fakeGitea([bumpPull(prBody("old", true))]);
+ await open({ call, contentCommit: "new", auto: false, log: quiet });
+ assert.deepEqual(
+ sent.map((s) => `${s.method} ${s.path}`),
+ [
+ "GET /pulls?state=open&limit=50",
+ "PATCH /pulls/5",
+ "POST /issues/5/comments",
+ "POST /actions/workflows/ci.yml/dispatches",
+ ],
+ );
+ const again = fakeGitea([bumpPull(prBody("new", false))]);
+ await open({ call: again.call, contentCommit: "newer", auto: false, log: quiet });
+ assert.ok(!again.sent.some((s) => s.path.includes("/comments")));
+ });
+
+ it("fails loudly when Gitea refuses", async () => {
+ const { call } = fakeGitea([], { "POST /actions/workflows/ci.yml/dispatches": 403 });
+ await assert.rejects(open({ call, contentCommit: "abc", auto: true, log: quiet }), /403/);
+ });
+});
+
+describe("content publish: merge", () => {
+ it("merges the PR CI built when it is marked auto, then dispatches main", async () => {
+ const { call, sent } = fakeGitea([bumpPull(prBody("abc", true))]);
+ assert.equal(await merge({ call, sha: "head-sha", log: quiet }), "merged");
+ assert.deepEqual(
+ sent.map((s) => `${s.method} ${s.path}`),
+ [
+ "GET /pulls?state=open&limit=50",
+ "POST /pulls/5/merge",
+ "POST /actions/workflows/ci.yml/dispatches",
+ ],
+ );
+ assert.deepEqual(sent[1].body, {
+ Do: "squash",
+ MergeTitleField: "chore(content): publish from admin (#5)",
+ head_commit_id: "head-sha",
+ delete_branch_after_merge: true,
+ });
+ assert.deepEqual(sent[2].body, { ref: "main" });
+ });
+
+ it("leaves alone: no PR, a PR that moved on, a PR waiting for review", async () => {
+ assert.equal(await merge({ call: fakeGitea([]).call, sha: "s", log: quiet }), "none");
+ const moved = fakeGitea([bumpPull(prBody("abc", true), "newer-sha")]);
+ assert.equal(await merge({ call: moved.call, sha: "head-sha", log: quiet }), "moved");
+ const review = fakeGitea([bumpPull(prBody("abc", false))]);
+ assert.equal(await merge({ call: review.call, sha: "head-sha", log: quiet }), "review");
+ for (const fake of [moved, review]) {
+ assert.ok(!fake.sent.some((s) => s.method !== "GET"));
+ }
+ });
+
+ it("says so on the PR when the merge is refused, and fails", async () => {
+ const { call, sent } = fakeGitea([bumpPull(prBody("abc", true))], {
+ "POST /pulls/5/merge": 405,
+ });
+ await assert.rejects(merge({ call, sha: "head-sha", log: quiet }), /405/);
+ const comment = sent.find((s) => s.path === "/issues/5/comments");
+ assert.match(String((comment?.body as { body: string }).body), /Merge it by hand/);
+ assert.ok(!sent.some((s) => s.path.includes("/dispatches")));
+ });
+});
--
2.54.1
From ab544d8ebaf874651182ce7c18241ba6343d5a01 Mon Sep 17 00:00:00 2001
From: poli0981
Date: Tue, 24 Nov 2026 00:47:41 +0700
Subject: [PATCH 09/25] fix(report): site bug reports become confidential
issues on the GitLab mirror
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The reports went to a private GitHub repository, which went with the account.
Decision D14 of the migration: issues on the GitLab mirror (gitlab.com/poli0981/
poli0981-dev, wrangler var REPORT_PROJECT) through GitLab's API, with a new Worker
secret GITLAB_ISSUES_TOKEN (Reporter role, scope api) in place of GITHUB_ISSUES_TOKEN.
Every report is created confidential: it carries the reporter's description, route
and browser details, and the privacy policy promises only the owner sees it (the
content repo's privacy §4 now names GitLab). Reporter text cannot ping anyone or run
a GitLab quick action: a line that starts with "/" gets a zero-width space in front.
When GitLab fails, the Discord notice still carries the report (202), as before.
Co-Authored-By: Claude Opus 5.5
---
astro.config.mjs | 7 +--
src/components/admin/SecurityPanel.svelte | 2 +-
src/lib/admin/status.ts | 4 +-
src/pages/api/report.ts | 52 +++++++++++++----------
tests/api-public.test.ts | 49 +++++++++++----------
tests/support/stubs/astro-env-server.ts | 6 +--
wrangler.jsonc | 9 ++--
7 files changed, 72 insertions(+), 57 deletions(-)
diff --git a/astro.config.mjs b/astro.config.mjs
index 2083ac8..a6f8619 100644
--- a/astro.config.mjs
+++ b/astro.config.mjs
@@ -124,8 +124,9 @@ export default defineConfig({
},
// Bug-report pipeline env (docs 10). All optional so the site builds + degrades
- // gracefully until the owner provisions them (Turnstile keys, a fine-grained GitHub
- // Issues token, and a Discord webhook). The client site key is public + inlined.
+ // gracefully until the owner provisions them (Turnstile keys, a GitLab token that may
+ // open issues on the mirror, and a Discord webhook). The client site key is public +
+ // inlined.
env: {
schema: {
PUBLIC_TURNSTILE_SITE_KEY: envField.string({
@@ -134,7 +135,7 @@ export default defineConfig({
optional: true,
}),
TURNSTILE_SECRET: envField.string({ context: "server", access: "secret", optional: true }),
- GITHUB_ISSUES_TOKEN: envField.string({ context: "server", access: "secret", optional: true }),
+ GITLAB_ISSUES_TOKEN: envField.string({ context: "server", access: "secret", optional: true }),
DISCORD_WEBHOOK_BUG: envField.string({ context: "server", access: "secret", optional: true }),
// Admin (admin.poli0981.dev), two fine-grained tokens (src/lib/admin/github.ts):
// content repo Contents RW, and site repo Actions RW for the publish workflow;
diff --git a/src/components/admin/SecurityPanel.svelte b/src/components/admin/SecurityPanel.svelte
index 4f26762..045d4aa 100644
--- a/src/components/admin/SecurityPanel.svelte
+++ b/src/components/admin/SecurityPanel.svelte
@@ -24,7 +24,7 @@
const SECRET_ROLES = {
GITHUB_CONTENT_TOKEN: "lưu nội dung từ admin",
GITHUB_PUBLISH_TOKEN: "xuất bản (token riêng, chỉ quyền Actions)",
- GITHUB_ISSUES_TOKEN: "báo lỗi → issue GitHub riêng tư",
+ GITLAB_ISSUES_TOKEN: "báo lỗi → issue bảo mật trên GitLab",
DISCORD_WEBHOOK_BUG: "báo lỗi → Discord",
TURNSTILE_SECRET: "Turnstile (cổng + báo lỗi)",
GATE_SECRET: "ký cookie của cổng Turnstile",
diff --git a/src/lib/admin/status.ts b/src/lib/admin/status.ts
index 879e17e..1dad869 100644
--- a/src/lib/admin/status.ts
+++ b/src/lib/admin/status.ts
@@ -4,7 +4,7 @@ import {
DISCORD_WEBHOOK_BUG,
GATE_SECRET,
GITHUB_CONTENT_TOKEN,
- GITHUB_ISSUES_TOKEN,
+ GITLAB_ISSUES_TOKEN,
GITHUB_PUBLISH_TOKEN,
TURNSTILE_SECRET,
} from "astro:env/server";
@@ -35,7 +35,7 @@ export function configStatus(): ConfigStatus {
secrets: {
GITHUB_CONTENT_TOKEN: Boolean(GITHUB_CONTENT_TOKEN),
GITHUB_PUBLISH_TOKEN: Boolean(GITHUB_PUBLISH_TOKEN),
- GITHUB_ISSUES_TOKEN: Boolean(GITHUB_ISSUES_TOKEN),
+ GITLAB_ISSUES_TOKEN: Boolean(GITLAB_ISSUES_TOKEN),
DISCORD_WEBHOOK_BUG: Boolean(DISCORD_WEBHOOK_BUG),
TURNSTILE_SECRET: Boolean(TURNSTILE_SECRET),
GATE_SECRET: Boolean(GATE_SECRET),
diff --git a/src/pages/api/report.ts b/src/pages/api/report.ts
index f23ca78..fe93c98 100644
--- a/src/pages/api/report.ts
+++ b/src/pages/api/report.ts
@@ -1,18 +1,23 @@
import type { APIRoute } from "astro";
import { env } from "cloudflare:workers";
import { z } from "zod";
-import { TURNSTILE_SECRET, GITHUB_ISSUES_TOKEN, DISCORD_WEBHOOK_BUG } from "astro:env/server";
+import { TURNSTILE_SECRET, GITLAB_ISSUES_TOKEN, DISCORD_WEBHOOK_BUG } from "astro:env/server";
import { BodyTooLargeError, readTextLimited } from "@/lib/body";
import { log } from "@/lib/log";
import { verifyTurnstile } from "@/lib/turnstile-server";
// On-demand so middleware runs (RL_REPORT: 5 per 60 s per client). Secrets are optional
-// at build so the site ships before they're provisioned; when TURNSTILE_SECRET or the GitHub
+// at build so the site ships before they're provisioned; when TURNSTILE_SECRET or the GitLab
// token is missing this route replies 503 and the client dialog degrades to a Discord fallback.
export const prerender = false;
-/** Private repo (wrangler.jsonc var): reports carry browser details and are never public. */
-const DEFAULT_REPORT_REPO = "poli0981/site-reports";
+/**
+ * The GitLab project (wrangler.jsonc var REPORT_PROJECT): the public mirror of this repo. The
+ * GitHub repository the reports used to go to went with the account; on GitLab every report
+ * is a CONFIDENTIAL issue, because reports carry browser details and are never public.
+ */
+const DEFAULT_REPORT_PROJECT = "poli0981/poli0981-dev";
+const GITLAB_API = "https://gitlab.com/api/v4";
const MAX_BODY = 32_000;
const TIMEOUT_MS = 10_000;
@@ -53,11 +58,13 @@ function json(data: unknown, status: number): Response {
}
/**
- * Reporter-supplied text is rendered as Markdown on GitHub. Break `@user` mentions (a zero-
- * width space after "@" — nobody gets pinged by a stranger's report) and backticks in
- * values that sit inside inline code.
+ * Reporter-supplied text is rendered as Markdown on GitLab. Break `@user` mentions (a zero-
+ * width space after "@" — nobody gets pinged by a stranger's report), quick actions (GitLab
+ * runs a line that starts with "/", such as `/close`, as a command: a zero-width space goes
+ * in front) and backticks in values that sit inside inline code.
*/
-const noMentions = (text: string) => text.replace(/@(?=[\w-])/g, "@");
+const noMentions = (text: string) =>
+ text.replace(/@(?=[\w-])/g, "@").replace(/^(\s*)\//gm, "$1/");
const inlineCode = (text: string) => `\`${text.replace(/`/g, "'")}\``;
/** A code fence longer than any backtick run inside, so the log can't close it early. */
@@ -100,31 +107,32 @@ function issueBody(body: ReportBody): string {
}
async function createIssue(body: ReportBody, token: string): Promise {
- const repo = (env as { REPORT_REPO?: string }).REPORT_REPO || DEFAULT_REPORT_REPO;
+ const project = (env as { REPORT_PROJECT?: string }).REPORT_PROJECT || DEFAULT_REPORT_PROJECT;
try {
- const res = await fetch(`https://api.github.com/repos/${repo}/issues`, {
+ const res = await fetch(`${GITLAB_API}/projects/${encodeURIComponent(project)}/issues`, {
method: "POST",
headers: {
- authorization: `Bearer ${token}`,
- accept: "application/vnd.github+json",
+ "private-token": token,
+ accept: "application/json",
"content-type": "application/json",
"user-agent": "poli0981-dev-report-bot",
},
body: JSON.stringify({
title: issueTitle(body),
- body: issueBody(body),
- labels: ["bug", "from-site"],
+ description: issueBody(body),
+ labels: "bug,from-site",
+ confidential: true,
}),
signal: AbortSignal.timeout(TIMEOUT_MS),
});
if (!res.ok) {
- log.error("report.github_failed", { status: res.status, repo });
+ log.error("report.gitlab_failed", { status: res.status, project });
return null;
}
- const data = (await res.json()) as { html_url?: string };
- return data.html_url ?? null;
+ const data = (await res.json()) as { web_url?: string };
+ return data.web_url ?? null;
} catch (error) {
- log.error("report.github_failed", { repo, error });
+ log.error("report.gitlab_failed", { project, error });
return null;
}
}
@@ -163,7 +171,7 @@ async function notifyDiscord(
}
export const POST: APIRoute = async ({ request }) => {
- if (!TURNSTILE_SECRET || !GITHUB_ISSUES_TOKEN) return json({ error: "not_configured" }, 503);
+ if (!TURNSTILE_SECRET || !GITLAB_ISSUES_TOKEN) return json({ error: "not_configured" }, 503);
let raw: string;
try {
@@ -189,12 +197,12 @@ export const POST: APIRoute = async ({ request }) => {
});
if (!verdict.ok) return json({ error: "turnstile_failed", reason: verdict.reason }, 400);
- const issueUrl = await createIssue(parsed, GITHUB_ISSUES_TOKEN);
+ const issueUrl = await createIssue(parsed, GITLAB_ISSUES_TOKEN);
if (DISCORD_WEBHOOK_BUG) await notifyDiscord(parsed, issueUrl, DISCORD_WEBHOOK_BUG);
log.info("report.received", { route: parsed.meta.route, filed: issueUrl !== null });
- // GitHub failed but Discord fired — the report is not lost (docs 10 §3). The issue lives
- // in a private repo, so its URL is not echoed back to the reporter.
+ // GitLab failed but Discord fired — the report is not lost (docs 10 §3). The issue is
+ // confidential, so its URL is not echoed back to the reporter.
if (!issueUrl) return json({ ok: true, degraded: true }, 202);
return json({ ok: true }, 201);
};
diff --git a/tests/api-public.test.ts b/tests/api-public.test.ts
index d724a14..5863058 100644
--- a/tests/api-public.test.ts
+++ b/tests/api-public.test.ts
@@ -100,7 +100,7 @@ describe("POST /api/gate", () => {
describe("POST /api/report", () => {
const report = {
- description: "The gallery lightbox closes when I press @someone's arrow keys",
+ description: "The gallery lightbox closes when I press @someone's arrow keys\n/close",
console: [{ ts: "2026-10-24T00:00:00Z", type: "error", message: "boom ``` breakout" }],
meta: {
route: "/gallery/`x`/",
@@ -126,52 +126,57 @@ describe("POST /api/report", () => {
beforeEach(() => {
setServerEnv({
TURNSTILE_SECRET: TEST_SECRET,
- GITHUB_ISSUES_TOKEN: "issues-token",
+ GITLAB_ISSUES_TOKEN: "issues-token",
DISCORD_WEBHOOK_BUG: "https://discord.example/webhook",
});
- setWorkerEnv({ REPORT_REPO: "poli0981/site-reports" });
+ setWorkerEnv({ REPORT_PROJECT: "poli0981/site-reports" });
});
it("is unavailable without its secrets, and refuses bad input", async () => {
setServerEnv({ TURNSTILE_SECRET: TEST_SECRET });
assert.equal((await post("{}")).status, 503);
- setServerEnv({ TURNSTILE_SECRET: TEST_SECRET, GITHUB_ISSUES_TOKEN: "t" });
+ setServerEnv({ TURNSTILE_SECRET: TEST_SECRET, GITLAB_ISSUES_TOKEN: "t" });
assert.equal((await post("x".repeat(40_000))).status, 413);
assert.equal((await post("{", { "content-length": "1" })).status, 400);
assert.equal((await post(JSON.stringify({ ...report, description: "short" }))).status, 400);
});
- it("files a private issue that can't ping anyone, then notifies Discord", async () => {
+ it("files a confidential issue that can't ping or command, then notifies Discord", async () => {
const { calls } = route({
[SITEVERIFY]: siteverify({ action: "report" }),
- "https://api.github.com/": () => jsonResponse({ html_url: "https://github.com/x/1" }, 201),
+ "https://gitlab.com/": () =>
+ jsonResponse({ web_url: "https://gitlab.com/poli0981/site-reports/-/issues/1" }, 201),
"https://discord.example/": () => new Response(null, { status: 204 }),
});
const response = await post(JSON.stringify(report));
assert.equal(response.status, 201);
assert.deepEqual(await response.json(), { ok: true });
- const issue = calls.find((c) => c.url.startsWith("https://api.github.com/"));
- assert.equal(issue?.url, "https://api.github.com/repos/poli0981/site-reports/issues");
+ const issue = calls.find((c) => c.url.startsWith("https://gitlab.com/"));
+ assert.equal(issue?.url, "https://gitlab.com/api/v4/projects/poli0981%2Fsite-reports/issues");
+ assert.equal(issue?.headers.get("private-token"), "issues-token");
const body = JSON.parse(issue?.body ?? "{}") as {
title: string;
- body: string;
- labels: string[];
+ description: string;
+ labels: string;
+ confidential: boolean;
};
assert.match(body.title, /^\[web-report\] /);
- assert.doesNotMatch(body.body, /@someone/); // the mention is broken up
- assert.match(body.body, /- Route: `\/gallery\/'x'\/`/);
- assert.match(body.body, /````\n\[2026-10-24T00:00:00Z\] error: boom ``` breakout\n````/);
- assert.deepEqual(body.labels, ["bug", "from-site"]);
+ assert.doesNotMatch(body.description, /@someone/); // the mention is broken up
+ assert.doesNotMatch(body.description, /^\/close/m); // no quick action at a line's start
+ assert.match(body.description, /- Route: `\/gallery\/'x'\/`/);
+ assert.match(body.description, /````\n\[2026-10-24T00:00:00Z\] error: boom ``` breakout\n````/);
+ assert.equal(body.labels, "bug,from-site");
+ assert.equal(body.confidential, true);
const discord = calls.find((c) => c.url.startsWith("https://discord.example/"));
assert.deepEqual(JSON.parse(discord?.body ?? "{}").allowed_mentions, { parse: [] });
});
- it("still succeeds (degraded) when GitHub fails, and survives Discord failing", async () => {
+ it("still succeeds (degraded) when GitLab fails, and survives Discord failing", async () => {
route({
[SITEVERIFY]: siteverify({ action: "report" }),
- "https://api.github.com/": () => jsonResponse({ message: "nope" }, 404),
+ "https://gitlab.com/": () => jsonResponse({ message: "nope" }, 404),
"https://discord.example/": () => {
throw new Error("discord down");
},
@@ -180,26 +185,26 @@ describe("POST /api/report", () => {
assert.equal(result.status, 202);
assert.deepEqual(
logs.map((line) => line.event),
- ["report.github_failed", "report.discord_failed", "report.received"],
+ ["report.gitlab_failed", "report.discord_failed", "report.received"],
);
});
- it("falls back to the default repo and survives a GitHub network error", async () => {
+ it("falls back to the mirror project and survives a GitLab network error", async () => {
setWorkerEnv({});
- setServerEnv({ TURNSTILE_SECRET: TEST_SECRET, GITHUB_ISSUES_TOKEN: "t" });
+ setServerEnv({ TURNSTILE_SECRET: TEST_SECRET, GITLAB_ISSUES_TOKEN: "t" });
const { calls } = route({
[SITEVERIFY]: siteverify({ action: "report" }),
- "https://api.github.com/": () => {
+ "https://gitlab.com/": () => {
throw new Error("network");
},
});
const { result } = await captureLogs(() => post(JSON.stringify(report)));
assert.equal(result.status, 202);
- assert.ok(calls.some((c) => c.url.includes("/repos/poli0981/site-reports/issues")));
+ assert.ok(calls.some((c) => c.url.includes("/projects/poli0981%2Fpoli0981-dev/issues")));
});
it("rejects a token minted for another form (with a real, non-test secret)", async () => {
- setServerEnv({ TURNSTILE_SECRET: "0x4AAAAAAA-real-secret", GITHUB_ISSUES_TOKEN: "t" });
+ setServerEnv({ TURNSTILE_SECRET: "0x4AAAAAAA-real-secret", GITLAB_ISSUES_TOKEN: "t" });
route({ [SITEVERIFY]: siteverify({ action: "gate" }) });
const response = await post(JSON.stringify(report));
assert.equal(response.status, 400);
diff --git a/tests/support/stubs/astro-env-server.ts b/tests/support/stubs/astro-env-server.ts
index 04c4b5a..a7f0b3b 100644
--- a/tests/support/stubs/astro-env-server.ts
+++ b/tests/support/stubs/astro-env-server.ts
@@ -2,7 +2,7 @@
// with setServerEnv(), and modules that imported the names see the change (ES live bindings).
export let TURNSTILE_SECRET: string | undefined;
-export let GITHUB_ISSUES_TOKEN: string | undefined;
+export let GITLAB_ISSUES_TOKEN: string | undefined;
export let DISCORD_WEBHOOK_BUG: string | undefined;
export let GITHUB_CONTENT_TOKEN: string | undefined;
export let GITHUB_PUBLISH_TOKEN: string | undefined;
@@ -11,7 +11,7 @@ export let GATE_SECRET: string | undefined;
export interface ServerEnv {
TURNSTILE_SECRET?: string;
- GITHUB_ISSUES_TOKEN?: string;
+ GITLAB_ISSUES_TOKEN?: string;
DISCORD_WEBHOOK_BUG?: string;
GITHUB_CONTENT_TOKEN?: string;
GITHUB_PUBLISH_TOKEN?: string;
@@ -22,7 +22,7 @@ export interface ServerEnv {
/** Replace the whole server env: names not given become unset. */
export function setServerEnv(values: ServerEnv = {}): void {
TURNSTILE_SECRET = values.TURNSTILE_SECRET;
- GITHUB_ISSUES_TOKEN = values.GITHUB_ISSUES_TOKEN;
+ GITLAB_ISSUES_TOKEN = values.GITLAB_ISSUES_TOKEN;
DISCORD_WEBHOOK_BUG = values.DISCORD_WEBHOOK_BUG;
GITHUB_CONTENT_TOKEN = values.GITHUB_CONTENT_TOKEN;
GITHUB_PUBLISH_TOKEN = values.GITHUB_PUBLISH_TOKEN;
diff --git a/wrangler.jsonc b/wrangler.jsonc
index f92aeed..058a364 100644
--- a/wrangler.jsonc
+++ b/wrangler.jsonc
@@ -89,10 +89,11 @@
// Not secrets: the AUD tag only says which app a token must be minted for.
"ACCESS_TEAM_DOMAIN": "https://polished-hall-48fd.cloudflareaccess.com",
"ACCESS_AUD": "197ec8eae1275e465623bdb77f88238b9b01dd66eec0be2e8c13ccd7b13e48b7",
- // Where /api/report files bug reports. A PRIVATE repo: reports carry the reporter's
- // description, route and browser details, and the privacy policy promises they are not
- // public. GITHUB_ISSUES_TOKEN must have Issues: read & write on it.
- "REPORT_REPO": "poli0981/site-reports",
+ // Where /api/report files bug reports: the GitLab mirror of this repo, as CONFIDENTIAL
+ // issues (src/pages/api/report.ts). Reports carry the reporter's description, route and
+ // browser details, and the privacy policy promises only the owner sees them.
+ // GITLAB_ISSUES_TOKEN must be allowed to open issues there (Reporter role, scope api).
+ "REPORT_PROJECT": "poli0981/poli0981-dev",
},
// Uploaded images (src/lib/media): public AVIF/WebP variants under v1/, private
// metadata-free masters and per-image metadata elsewhere. The bucket has no public
--
2.54.1
From e528dcf6ac7e538a45e913c0906deb7075bf882d Mon Sep 17 00:00:00 2001
From: poli0981
Date: Tue, 24 Nov 2026 00:47:56 +0700
Subject: [PATCH 10/25] fix(admin): content saves and publishing through Gitea
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The admin read and wrote poli0981/content through GitHub's REST, Git Data and GraphQL
APIs with two fine-grained tokens; both went with the account. src/lib/admin/gitea.ts
replaces src/lib/admin/github.ts (decision D12 of the migration):
- One Worker secret, GITEA_BOT_TOKEN: a write:repository token of the bot user
poli0981-bot, a Write collaborator on the content and site repos only. Gitea scopes
a token by its user's access, not by repository, so the old content/publish token
split (and the admin's single-token warnings) goes; the bot still pushes nothing to
the site repo, publishing goes through content-bump.yml.
- Listing: the branch head, the recursive tree, then the file contents in batches of
50 (POST …/file-contents), instead of one GraphQL query.
- Saving: Gitea's change-files call commits every file in one commit and checks each
file's sha itself, the lock that replaces the ref fast-forward and its retry; a stale
sha becomes the same ConflictError as before.
- Publish status: the open content/bump PR, its `CI / build (…)` commit status, its
body marker for "merges itself", and the last content-bump.yml run.
- Links to commits and runs point at git.poli0981.dev; a refused token reads as
gitea_permission with what the bot needs.
Co-Authored-By: Claude Opus 5.5
---
astro.config.mjs | 13 +-
src/components/admin/ActivityLog.svelte | 2 +-
src/components/admin/Dashboard.svelte | 14 +-
src/components/admin/Editor.svelte | 2 +-
src/components/admin/PublishBar.svelte | 14 +-
src/components/admin/SecurityPanel.svelte | 13 +-
src/components/admin/api.ts | 5 +-
src/lib/admin/autopublish.ts | 14 +-
src/lib/admin/gitea.ts | 325 ++++++++++++++++++++++
src/lib/admin/github.ts | 307 --------------------
src/lib/admin/http.ts | 13 +-
src/lib/admin/status.ts | 9 +-
src/pages/api/admin/activity.ts | 8 +-
src/pages/api/admin/content.ts | 26 +-
src/pages/api/admin/gallery.ts | 22 +-
src/pages/api/admin/media.ts | 12 +-
src/pages/api/admin/overview.ts | 6 +-
src/pages/api/admin/publish.ts | 32 +--
tests/admin-ops.test.ts | 29 +-
tests/admin.test.ts | 128 +++++----
tests/client.test.ts | 5 +-
tests/support/gitea.ts | 220 +++++++++++++++
tests/support/github.ts | 184 ------------
tests/support/stubs/astro-env-server.ts | 9 +-
24 files changed, 712 insertions(+), 700 deletions(-)
create mode 100644 src/lib/admin/gitea.ts
delete mode 100644 src/lib/admin/github.ts
create mode 100644 tests/support/gitea.ts
delete mode 100644 tests/support/github.ts
diff --git a/astro.config.mjs b/astro.config.mjs
index a6f8619..c55be1c 100644
--- a/astro.config.mjs
+++ b/astro.config.mjs
@@ -137,15 +137,10 @@ export default defineConfig({
TURNSTILE_SECRET: envField.string({ context: "server", access: "secret", optional: true }),
GITLAB_ISSUES_TOKEN: envField.string({ context: "server", access: "secret", optional: true }),
DISCORD_WEBHOOK_BUG: envField.string({ context: "server", access: "secret", optional: true }),
- // Admin (admin.poli0981.dev), two fine-grained tokens (src/lib/admin/github.ts):
- // content repo Contents RW, and site repo Actions RW for the publish workflow;
- // plus the email allowlist on top of Access (unset = the admin refuses everyone).
- GITHUB_CONTENT_TOKEN: envField.string({
- context: "server",
- access: "secret",
- optional: true,
- }),
- GITHUB_PUBLISH_TOKEN: envField.string({
+ // Admin (admin.poli0981.dev): the Gitea token of the bot user poli0981-bot, a Write
+ // collaborator on the content and site repos (src/lib/admin/gitea.ts); plus the email
+ // allowlist on top of Access (unset = the admin refuses everyone).
+ GITEA_BOT_TOKEN: envField.string({
context: "server",
access: "secret",
optional: true,
diff --git a/src/components/admin/ActivityLog.svelte b/src/components/admin/ActivityLog.svelte
index 9ad41c1..29c4043 100644
--- a/src/components/admin/ActivityLog.svelte
+++ b/src/components/admin/ActivityLog.svelte
@@ -4,7 +4,7 @@
import { ago, dateTime, shortSha } from "./format";
/** @typedef {import("@/lib/admin/audit").AuditEntry} AuditEntry */
- /** @typedef {import("@/lib/admin/github").ContentCommit} ContentCommit */
+ /** @typedef {import("@/lib/admin/gitea").ContentCommit} ContentCommit */
/** @type {{ audit: AuditEntry[]; commits: ContentCommit[] } | null} */
let data = $state(null);
diff --git a/src/components/admin/Dashboard.svelte b/src/components/admin/Dashboard.svelte
index 4d201a4..c621925 100644
--- a/src/components/admin/Dashboard.svelte
+++ b/src/components/admin/Dashboard.svelte
@@ -59,7 +59,7 @@
{#if overview.config.version.commit}
· commit
@@ -119,7 +119,7 @@
{#if drafts}· {drafts} bản nháp chưa hiện trên site{/if}
{:else}
-
Chưa đặt GITHUB_CONTENT_TOKEN — admin không đọc được repo nội dung.
+
Chưa đặt GITEA_BOT_TOKEN — admin không đọc được repo nội dung.