Files
poli0981andClaude Opus 5.5 981e625ca1
CI / build (push) Successful in 3m19s
CI / gates (push) Successful in 1m5s
CI / record (push) Skipped
Reusable / Qodana / Qodana (push) Successful in 3m7s
Qodana / qodana (push) Successful in 3m7s
Reusable / Security / Secrets (gitleaks) (push) Successful in 10s
Reusable / Security / Rust (cargo-deny) (push) Skipped
Reusable / Security / .NET (NuGetAudit) (push) Skipped
Reusable / Security / SAST (Opengrep) (push) Successful in 24s
Reusable / Security / Dependencies (osv-scanner) (push) Successful in 17s
Security / security (push) Successful in 52s
CI / deploy (push) Successful in 1m9s
chore: move the repository to Gitea (D38) (#1)
- ci: move the workflows to Gitea Actions (D38)
- feat(site): source on Gitea, issues and bug reports on the GitLab mirror
- docs: where the project lives now — Gitea, the GitLab mirror, e-mail
- docs: the suite on Gitea — D38, CI/CD rewritten, every GitHub-era claim synced
- fix(ci): what the first Gitea runs found — Qodana and gitleaks
- fix(ci): .gitleaksignore describes the Sonar key instead of quoting it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 05:29:57 +00:00

26 KiB
Raw Permalink Blame History

12 — CI/CD & Repo Automation

Forge since 2026-11-24 (D38): the repository lives on the owner's Gitea, https://git.poli0981.dev/poli0981/softharbor (origin); CI is Gitea Actions in .gitea/workflows/; the public files issues and merge requests on the push mirror gitlab.com/poli0981/softharbor, where no CI runs. The GitHub account was suspended in November 2026 — the github remote is kept for history and never pushed. The procedure every repository of the owner followed is the runbook docs/GITEA-MIGRATION.md in poli0981/.github (its docs/migration/softharbor.md is this repository's guide); for migration topics it wins over this file.

1. Overview

PR ──▶ CI (build + gates) + Security + Qodana ──▶ review ──▶ squash to main
                                                                 │
         ┌───────────────────────────────────────────────────────┤
         ▼                                                       ▼
   CI `deploy` job (push to main only)                 quarantine.yml (paths)
   pnpm build ─▶ wrangler deploy ─▶ wait until production serves the build
cron (13:00–16:00 UTC only) ─▶ quarantine 13:17 daily · vt-recheck 13:59 daily
     · link-check Mon 14:43 · Security Tue 15:37 · Renovate (central, 13:31)
release published by hand ─▶ notify.yml ─▶ Discord

The runner is the maintainer's PC. One Gitea runner, user-scoped to the poli0981 repositories; ubuntu-latest jobs run in Docker (docker.gitea.com/runner-images) as root. Consequences:

  • Jobs run only while the PC is on. A scheduled run whose slot passes while it is off waits as "waiting" and starts when the runner comes back; after 24 h unpicked it is cancelled (Gitea's ABANDONED_JOB_TIMEOUT). Delays are accepted (runbook §7).
  • Every cron sits inside 13:00–16:00 UTC (20:00–23:00 Vietnam), on a minute no other repository of the owner uses — the slots are registered in poli0981/.github docs/migration/README.md. Never schedule inside Gitea's nightly backup window (19:30–19:45 UTC). No TZ= prefix.
  • Background processes die with their step (a server started with & is gone in the next step), and inside the container localhost can resolve to ::1 for a server and to 127.0.0.1 for a client — so playwright.config.ts binds and calls 127.0.0.1 explicitly, and starts its servers itself.
  • Artifact uploads are continue-on-error. They use christopherhx/gitea-upload-artifact (upstream v4 refuses non-GitHub servers), and the route from the runner to the artifact store has dropped uploads mid-way (ticktune, 2026-11-23) — a lost report must never make a red run confusing.
  • No macOS runner, no OIDC, no code-scanning UI, no Dependabot, no CodeQL (runbook §1). What replaced each is below.

Permissions. Every workflow declares permissions: {} at the top and grants per job; checkouts use persist-credentials: false. The job token is ${{ github.token }} (Gitea also calls it GITEA_TOKEN); its API is ${{ github.api_url }} (https://git.poli0981.dev/api/v1). Gitea knows contents, issues, pull-requests, actions and packages; GitHub-only scopes (id-token, checks, security-events, statuses, …) are gone from every workflow.

Two Gitea facts shape the bots (runbook §6):

  1. An event caused by the job token starts no workflow — as on GitHub. A branch the bot pushes, or a PR it opens, runs no pull_request checks, so the bot dispatches ci.yml and security.yml on its branch.
  2. A dispatched run writes no commit status (measured on Gitea 28.4 by poli0981-dev, 2026-11-24): its checks never meet branch protection. ci.yml's record job therefore writes build's and gates' results as statuses itself, named CI / build (workflow_dispatch) and CI / gates (workflow_dispatch) — names the protection patterns match.

scripts/gitea.mjs is the bots' side of the forge — PRs, dispatches, issues, statuses — over the REST API with the job token (no gh: it only talks to github.com). Its tests run it against an in-process stand-in for the API (scripts/gitea.test.ts).

Pinning. Every third-party uses: is pinned to a full commit SHA with the release in a comment (@<sha> # vX.Y.Z); Renovate bumps both. A bare owner/action@ref resolves to github.com; a Gitea-hosted action needs its full URL. The ops repository's workflows are pinned to the commit of an ops tag — 8e6582af… # ops v2026.11.2 — by hand: Renovate reads no version in # ops … and skips them. Tools downloaded by checksum (osv-scanner in gates) are bumped by hand too, version and SHA-256 together.

Pinned as of 2026-11-24: actions/checkout v7.0.1 · pnpm/action-setup v6.1.1 (no version: — it reads packageManager) · actions/setup-node v7.1.0 (node-version-file: .nvmrc) · actions/cache v6.1.0 · christopherhx/gitea-upload-artifact v4 · lycheeverse/lychee-action v2.9.0 · osv-scanner v2.7.1 (binary) · ops v2026.11.2 (security.yml, reusable-qodana.yml, announce-release.yml).

2. The workflows

.gitea/workflows/ci.yml (CI) — self-contained, deliberately. It once called poli0981/.github → reusable-web-react.yml, which ran lint / typecheck / test only if a matching package script existed: rename a script and CI silently stops checking while still going green. This project's gates are the product, and it has shipped silent no-ops before (a dead set:html lint rule, workbox globs matching nothing, an unregistered service worker, CSP-dropped inline styles). The duplicated "logic" is a handful of pnpm invocations. Triggers: pull_request, push to main, workflow_dispatch (the bots, §4). Concurrency cancels superseded runs except on main. Jobs:

  • build (30 min cap) — install (frozen lockfile) → pnpm lint (ESLint + Prettier) → pnpm check (types) → pnpm coverage (the unit run itself, failing below the thresholds in vitest.config.ts) → pnpm build — the same command the deploy job runs, carrying its own gates: validate:data → i18n:check → astro build → postbuild:html → check:csp → check:assets → check:sw → check:feed → wrangler deploy --dry-run (bundles worker/ and validates wrangler.jsonc — bindings, assets, run_worker_first — without credentials) → pnpm knip → Playwright e2e on that build (docs/11 §5) — astro preview for the pages, wrangler dev for the Worker and its rate limits; the Chromium download is cached per Playwright version (on a hit only the OS libraries are installed), and the HTML report is kept as an artifact when the job fails.
  • gates (15 min cap) — validate:data, i18n:check, osv-scanner over pnpm-lock.yaml (the pinned, checksum-verified binary the ops security.yml uses; osv-scanner.toml next to the lockfile holds the time-boxed exceptions, docs/09 §7), pnpm audit --prod, and on PRs the changed-links lychee sweep (§5).
  • record — only on workflow_dispatch: records build and gates as commit statuses (§1, fact 2). Cancelled or skipped jobs record nothing.
  • deploy — only on a push to main, after build and gates pass (§3).

.gitea/workflows/security.yml (Security) — a caller of the ops repository's security.yml with node: true, on pushes to main, PRs, a weekly slot (37 15 * * 2) and dispatch. It replaced CodeQL, which Gitea does not have:

  • secrets — gitleaks over the whole history. Public identifiers it would flag (the Turnstile site key, the Web Analytics token, test fixtures) are listed in .gitleaksignore as commit:file:rule:line, each with its reason. A real secret never goes there: it is rotated.
  • sast — Opengrep with pinned community rules for JavaScript/TypeScript, --taint-intrafile; report-only, the SARIF kept as an artifact.
  • deps — osv-scanner over every lockfile it finds; fails on a known vulnerability.

Not a required check: gates is the one that blocks a merge on an advisory.

.gitea/workflows/qodana.yml (Qodana, D35) — a caller of the ops reusable-qodana.yml (the Qodana CLI 2026.3.1, pinned and checksum- verified) with package-manager: pnpm, node-version-file: .nvmrc and prepare-command: pnpm exec astro sync; secret QODANA_TOKEN (the Qodana Cloud project token that carries the Ultimate licence qodana-js needs). On PRs, pushes to main and dispatch; no schedule. Scope and gate live in qodana.yaml:

  • Native mode (withinDocker: 'false'): the linter runs in the job's own container after the install, so it resolves imports against the real install on Node 26.
  • Profile qodana.recommended; the dataset, build/test output and local tool state excluded. qodana-js reads .ts/.js/.mjs, JSON, YAML, Markdown and CSS; .astro and .svelte are outside its language list. JetBrains' Astro and Svelte plugins were tried and dropped (2026-11-15): under Qodana their type checks were not deterministic (one commit flipped between 0 and 15 errors). astro check, ESLint, the Vitest island suites and e2e cover those files.
  • Gate: failureConditions.severityThresholds.any: 0 — any finding turns the job red. A false positive with a known cause is switched off in qodana.yaml, with its reason — never with noinspection comments.
  • Findings live in Qodana Cloud (project softharbor) and the run's qodana-report artifact; Gitea has no code-scanning UI, so the SARIF upload to GitHub code scanning went (D38). Runs started by renovate-bot skip the scan: Gitea gives same-repo PRs the secrets, and such a run installs the very update under review.
  • Not required: a Qodana Cloud outage or a lapsed licence must never block a merge. The licence runs until 2026-12-31 — renew it, or every run turns red from 2027-01-01. The Qodana Cloud project's VCS URL must name the Gitea repository (maintainer).

.gitea/workflows/notify.yml (published release → Discord) — a caller of the ops announce-release.yml, pinned to the ops tag's commit, with ops_ref set to the same SHA (the notifier script is loaded from that commit) and only DISCORD_RELEASES_WEBHOOK passed — never secrets: inherit. It reads the release from Gitea's API. Publish the release by hand in Gitea (docs/13 §3): a release a workflow created with the job token would fire no release: published event. Re-announce with Actions → notify → Run workflow and the tag. Release notes go straight to Discord, so they must be final before publishing.

Scope note. notify.yml fires once per tagged release and reaches Discord only. The multi-platform notify.py cross-poster consumes /rss.xml on its own schedule (docs/03 §7, docs/13 §5): per-app announcements need no workflow here — only a valid, deterministic feed.

Removed with GitHub (D38): codeql.yml (→ security.yml), the sonar job and sonar-project.properties (SonarQube Cloud dropped in every repository of the owner, runbook D1 — Qodana and Opengrep cover the analysis), the SARIF upload, .github/dependabot.yml (→ Renovate, §6), and the "Allow GitHub Actions to create pull requests" setting the bots needed.

3. Deploy

ci.yml's deploy job is the only thing that deploys (D38). Cloudflare Workers Builds pulled from the GitHub repository and stopped with it; it is not reconnected to the GitLab mirror, which would deploy a second time on every mirror push (runbook D3).

Trigger What happens
push to main after build + gates pass: install → pnpm build → pnpm exec wrangler deploy --message "main <sha7>" — assets and the Worker — then poll https://softharbor.net/api/apps.json?deploy=<sha> until its generatedAt equals dist/api/apps.json's (30 × 5 s)
pull request nothing — no preview versions
  • CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID are user-level Gitea Actions secrets (shared by the owner's Workers projects) and appear in the deploy job only, which runs only for pushes to main. Gitea gives same-repository PRs the secrets — Renovate's included — so no job a branch can run ever sees the token; that is also why PR previews went.
  • The token needs Workers Scripts → Edit on the account. wrangler.jsonc declares no routes (docs/16 §3): the two custom domains are attached in the dashboard, and a deploy leaves them alone — so no zone scopes are needed. If a route or custom_domain is ever declared, the token needs Zone → Workers Routes → Edit and Zone → DNS → Edit too (a local wrangler deploy uses OAuth with full rights and will not reveal the gap).
  • The Worker's runtime secret TURNSTILE_SECRET lives on the Worker and survives every deploy. Build-time variables do not exist: the build reads no environment.
  • Verify after the job (docs/13 §3): the job already waits for the new build; spot-check the response headers, /api/verify answering JSON, /rss.xml, and the hashed /_astro/ names (builds are not byte-identical: each astro-island carries a random uid).
  • Rollback: dashboard → the Worker → Deployments → promote a previous version, or wrangler rollback locally. A local pnpm deploy still works for the maintainer but bypasses CI; prefer reverting on main.
  • preview_urls stays true in wrangler.jsonc, and _headers still marks *.workers.dev hosts noindex: a hand-made wrangler versions upload remains possible, but nothing makes one.

4. Quarantine workflow (repo-local)

.gitea/workflows/quarantine.yml — enforces hard rule 5 mechanically. On data pushes to main, daily at 13:17 UTC (was 02:17 on GitHub) and on dispatch; concurrency: quarantine. The job (contents, pull-requests, issues, actions: write):

  1. node scripts/quarantine.mjs (also pnpm quarantine, for the maintainer): scans src/data/apps/*.json and moves each status === 'flagged' file to data/quarantine/ (a rename; the directory is created on first use). It skips unparseable files (L1/L2's job), refuses a non-slug filename, never overwrites a quarantined copy and emits the moved output (space-separated slugs). Idempotent.
  2. If anything moved: commit to quarantine/auto as SoftHarbor bot (actions@noreply.git.poli0981.dev) and force-push it with the job token (an AUTHORIZATION: basic extra header, the way actions/checkout persists credentials — but only for this push, never while repository code runs).
  3. gitea.mjs pr opens — or updates — the PR quarantine/auto → main (labels security, quarantine), gitea.mjs dispatch runs ci.yml and security.yml on the branch, and gitea.mjs quarantine-issues opens [quarantine] <slug> for each slug that has no open issue yet.

The PR (not a direct push) keeps a human in the loop on main, while the daily run guarantees a flagged entry does not outlive the next evening even if a reviewer missed it. Normally it never fires: validate:data fails a PR that flags an entry without moving it. Step outputs reach shell bodies only through env:, never ${{ }} inside run:; gitea.mjs validates slugs before they reach an issue title.

The bot's commits are unsigned — Gitea has no API that signs a commit for the job token — which is why branch protection does not require signed commits (§8). A label that does not exist on the repository is left off with a notice (Gitea's API attaches labels by id and creates none).

4b. VirusTotal re-check (repo-local)

.gitea/workflows/vt-recheck.yml + scripts/vt-recheck.mjs (added 2026-10-23, D30) — docs/09 §6 step 5 made assisted, so no dated security claim can go stale unnoticed.

  • What it scans: each entry's links.download page. POST /urls submits it, a second pass reads GET /analyses/{id}, and the permalink is https://www.virustotal.com/gui/url/<sha256>. The canonical form keeps a #fragment: the API puts it in the id (measured 2026-10-23), while a scan submitted from a browser never sends one.
  • What it writes: only the three security lines, patched in place so Prettier's layout survives; never addedAt/updatedAt — the feed orders by addedAt, and notify.py announces anything it has not seen.
  • The rules: zero malicious/suspicious ⇒ fresh evidence + checkedAt, status unchanged; any detection ⇒ clean becomes unverified and a [vt] <slug> issue (label security) asks the maintainer to decide; promote slugs go unverified → clean only on a clean scan. It never sets flagged — quarantine stays a human pnpm quarantine (§4). An analysis in which no engine answered is "not checked", not clean.
  • Who is due: the slugs input first, then never-scanned entries, then drifted evidence (at most weekly), then checks older than max_age (default 90 days), oldest first.
  • Limits: the Public API allows 4 requests a minute and 500 a day (reset at 00:00 UTC), and counts every call. The script paces at 15.5 s, spends at most budget (default 440, capped at 500) with no more than half of it on submissions, backs off 60 s once on a 429 and treats a second as the day's quota — keeping what it finished. A refused key fails the step; a missing key is a no-op that says so. concurrency: vt-recheck keeps two runs off one key. Daily at 13:59 UTC (was 00:41 on GitHub, right after the reset; any hour fits one run's 440 requests).
  • On main (daily cron, or dispatch): one PR, vt/recheck. While it is open (gitea.mjs pr-open), each run first carries its results (git archive of the branch into $RUNNER_TEMP; a block is adopted only if its download link is unchanged and its check is newer), so the PR accumulates day by day. Then it commits src/data/apps to vt/recheck and force-pushes — only if the tree differs from the branch's, since the carried results alone make changed non-zero every day — opens or updates the PR, dispatches ci.yml and security.yml on it, and opens [vt] <slug> issues (gitea.mjs vt-issues). Merged branches are deleted, and a PR closed unmerged is never carried.
  • On any other branch (preview): dispatch it on the data branch (Actions → vt-recheck → Run workflow → the branch) and it scans only the slugs given — or, with none, the entries without a scan, i.e. a data PR's new apps. It prints the diff of the patched security blocks in the log (readable without signing in to download anything) and keeps the files and the report as the vt-preview artifact (7 days). No PR, no issues: the maintainer copies only the security blocks into the data PR — a whole file from the dispatch commit would revert later edits.
  • Terms: VirusTotal offers the Public API to sites "free to consumers"; it "must not be used in business workflows that do not contribute new files" and "can not be used as a substitute for antivirus products". SoftHarbor is free, carries no ads and only submits public download URLs; the site copy keeps making no safety claim (hard rule 4).

.gitea/workflows/link-check.yml — the weekly full sweep, Monday 14:43 UTC (was 04:43): scripts/extract-urls.mjs lists every links.* and evidence URL, lychee checks them (--max-concurrency 4 --retry-wait-time 10 --max-retries 5 --timeout 45 --accept '200..=299,403,429', fail: false), and gitea.mjs link-rot keeps one tracking issue, link-check: broken official links (label link-rot): replaced with the new report and a comment linking the run while the sweep fails, opened on the first failure, closed the first week it comes back clean. On GitHub an earlier version opened a fresh issue on every red run and left 12 duplicates open.

403 and 429 count as reachable in both sweeps (decision of 2026-07-30, docs/15 §4): 14 of the first 26 failures were bot mitigation on plainly live vendor sites. 404/5xx/connection failures still fail. Do not add --user-agent: spoofing a browser cleared the 403s but made other vendors answer 406/400.

PR-time link checking covers only the links the PR adds or edits — the URLs on the added lines of its diff. It runs as the last two steps of ci.yml's gates job (§2): git diff -U0 runs under set -euo pipefail and pipes into extract-urls.mjs --added (a failed diff stops the job rather than silently narrowing the check), and lychee is skipped when there is nothing to check — an empty input is a configuration error to lychee, and a skipped step stays visible where a green "0 links" would not. Changed 2026-10-23: it used to check every link of every touched file, and the first vt/recheck PR — 198 rewritten security blocks — failed three times on ~700 unrelated vendor links.

6. Dependency & scanning automation

Renovate (D38) replaces Dependabot: the owner's self-hosted Renovate runs from poli0981/renovate-config daily at 13:31 UTC over every repository the renovate-bot user can write to. renovate.json extends the shared preset (local>poli0981/renovate-config):

What the preset does
base config:recommended, the Dependency Dashboard issue
actions every uses: pinned to a SHA with its version comment, looked up over git (git ls-remote) — there is no github.com token
grouping all minor + patch updates in one PR; majors separate
age a new npm release is proposed only once it is 3 days old — which also keeps pnpm 11's own 24 h minimumReleaseAge from failing a release-day update at pnpm install --frozen-lockfile
security OSV advisories open their own PRs (labels dependencies + security) without the age wait; the dashboard lists the open ones

This repository adds three rules: no majors for typescript / @typescript/native (D21 as amended — the TS 6 API wrapper and TS 7 run side by side), for node / @types/node (the typings track the Node major in .nvmrc, docs/01 §5 rule 4) and for pnpm (11.x by decision). Those are platform moves, made deliberately. No schedule here: the runner's cron is the schedule. The ops pins (# ops v…) and the osv-scanner binary are bumped by hand. Maintainer setup (once): renovate-bot as a Write collaborator and the labels dependencies + security (maintainer/gitea-repo-setup.ps1 in the ops repository; both labels exist since 2026-11-23).

Scanning: osv-scanner and pnpm audit --prod in gates (required, every PR and push), the ops security.yml (gitleaks, Opengrep, osv-scanner) and Qodana. A finding in gates fails the job (policy docs/01 §5).

7. Issue templates

Two sets, kept in step:

  • .gitlab/issue_templates/ — what the public uses, on the GitLab mirror: Bug.md, App request.md, Listing change.md, Accessibility.md, and .gitlab/merge_request_templates/Default.md. Each ends with a /label ~… quick action (applied when the maintainer edits the issue). GitLab reads no issue forms, so these are Markdown with checklists.
  • .github/ISSUE_TEMPLATE/*.yml + .github/PULL_REQUEST_TEMPLATE.md — the forms Gitea reads (it reads .gitea/ISSUE_TEMPLATE, .github/ISSUE_TEMPLATE and .github/issue_template); only the maintainer can open issues there.

Bug.md is the layout the site's Report a bug link fills in (src/lib/issueUrl.ts, docs/05 §A6): ### Page URL, ### What happened / expected, ### Browser & OS, ### Console output. Change one with the other. Until 2026-11-24 the GitHub form's field ids (page-url, environment, console-output) were the prefill query parameters.

The Accessibility template (D33) asks only what got in the way and the page address; steps, environment, a severity (Critical / Serious / Moderate / Minor — confirmed in triage) and a screenshot are optional; it names the e-mail route accessibility@poli0981.dev (no account needed) and never asks about disability. Listing change (D36): which app, what should change (remove / correct a link / correct a detail / re-check), the evidence; it sends a suspected malicious download to security@ by e-mail and a developer to takedown@. .github/ISSUE_TEMPLATE/config.yml: blank issues off; contact links to code@ (questions), the Accessibility statement and SECURITY.md (e-mail only).

The PR template (v1.4; v1.4.1 adds the D36 box): what and why with the linked issue, the CI gates, docs and i18n parity, the accessibility checklist and a data-PR block (docs/00 §3, docs/09 §6, original EN/VI summaries, unverified entry, official links).

8. Branch protection (Gitea, main)

Gitea branch protection on main (D6 in the runbook; set by the maintainer in Settings → Branches):

  • Changes arrive by pull request; pushing to main is the owner's only; no force push, no deletion; 0 required approvals (single-maintainer repository — .gitea/CODEOWNERS only requests the review).
  • Required status checks: the patterns CI / build (*) and CI / gates (*). Gitea names a check <workflow> / <job> (<event>), so the (*) matches the pull_request, push and workflow_dispatch runs alike — the last written by record (§1). Renaming the workflow (CI) or a job breaks the rule until it follows. Security and Qodana are not required: an outside service's outage must never block a merge.
  • Signed commits are not required: the bots' commits cannot be signed (§4). The maintainer's own commits are still GPG-signed locally, and Gitea verifies them against the key on the account (https://git.poli0981.dev/poli0981.gpg).
  • Merge method: squash. The squash title must be a valid conventional commit, and the body should carry every commit subject from the branch (docs/10 §5). A branch stacked on a squashed one is replayed with git rebase --onto origin/main <old-branch>.

.gitea/CODEOWNERS (Gitea reads it from the root, docs/ or .gitea/ only, and treats each pattern as a regular expression): .* plus the high-risk paths ^\.gitea/, ^scripts/, ^src/data/, ^worker/ (T6). Until 2026-11-24 this was GitHub's ruleset "Run" (PR, signed commits, linear history, checks build, gates, codeql / Analyze (javascript-typescript)).