Merge branch 'chore/gitea-migration': ops repo on Gitea Actions

Runbook GITEA-MIGRATION.md §4.1, §4.3, §4.4 for poli0981/.github:
- workflows moved to .gitea/workflows; CodeQL / Dependabot workflows removed
- 13 reusables ported (SHA-pinned actions, Gitea artifact actions,
  R2 releases via vpk s3 / publish-r2, Workers deploy, macOS disabled)
- new reusables: security.yml (gitleaks, Opengrep, osv-scanner,
  cargo-deny, NuGetAudit) and publish-r2.yml (rclone to R2)
- Discord notifiers on the Gitea API; weekly digest ported and
  scheduled at `7 14 * * 0`

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
poli0981andClaude Opus 5.5 committed 2026-11-23 10:50:35 +07:00
commit 2c0850f2bf
31 files changed
+1912 -1194

No files matched your search

@@ -1,16 +1,29 @@
name: Reusable — Announce Release to Discord
# Reusable. Caller minimum:
# Reusable. Caller minimum (Gitea):
#
# on:
# release: { types: [published] }
# workflow_dispatch:
# inputs:
# tag: { required: true, type: string }
# permissions:
# contents: read
# jobs:
# announce:
# uses: poli0981/.github/.github/workflows/announce-release.yml@main
# secrets: inherit
# uses: poli0981/.github/.gitea/workflows/announce-release.yml@<full-sha> # ops vYYYY.MM.N
# with:
# tag_override: ${{ inputs.tag }}
# secrets: # explicit; `secrets: inherit` is VERIFY on Gitea
# DISCORD_RELEASES_WEBHOOK: ${{ secrets.DISCORD_RELEASES_WEBHOOK }}
# DISCORD_REPO_WEBHOOK: ${{ secrets.DISCORD_REPO_WEBHOOK }}
# DISCORD_PING_ROLE_ID: ${{ secrets.DISCORD_PING_ROLE_ID }}
#
# Gitea port 2026-11-23: release data comes from the Gitea API
# (GET {api_url}/repos/{owner}/{repo}/releases/tags/{tag}, same field names as GitHub)
# instead of `gh api`. Gitea releases carry notes + links only (no binaries), so the
# "Downloads" field is normally empty — the links are in the release body.
# VERIFY: the job token can read poli0981/.github from a caller repo (sparse checkout below).
on:
workflow_call:
@@ -34,9 +47,11 @@ jobs:
announce:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
steps:
- name: Fetch notifier script from ops repo
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: poli0981/.github
ref: main
@@ -45,10 +60,11 @@ jobs:
.github/scripts
sparse-checkout-cone-mode: false
- name: Resolve release data
- name: Resolve release data (Gitea API)
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
API_URL: ${{ github.api_url }}
INPUT_TAG: ${{ inputs.tag_override }}
EVENT_TAG: ${{ github.event.release.tag_name }}
run: |
@@ -60,7 +76,11 @@ jobs:
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
REL_JSON=$(gh api "repos/${GITHUB_REPOSITORY}/releases/tags/$TAG")
API_URL="${API_URL:-${GITHUB_SERVER_URL}/api/v1}"
REL_JSON=$(curl -fsSL --retry 3 \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Accept: application/json" \
"${API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/$(jq -rn --arg t "$TAG" '$t|@uri')")
NAME=$(echo "$REL_JSON" | jq -r '.name // ""')
BODY=$(echo "$REL_JSON" | jq -r '.body // ""')
URL=$(echo "$REL_JSON" | jq -r '.html_url // ""')
@@ -124,4 +144,4 @@ jobs:
RELEASE_PRERELEASE: ${{ steps.release.outputs.prerelease }}
RELEASE_PUBLISHED_AT: ${{ steps.release.outputs.published_at }}
RELEASE_ASSETS_JSON: ${{ steps.release.outputs.assets }}
run: python ops/.github/scripts/discord_notify.py release
run: python3 ops/.github/scripts/discord_notify.py release
@@ -1,17 +1,29 @@
name: Reusable — Notify CI Failures to Discord
# Reusable workflow. Callers should pass the failed workflow run context via
# `on: workflow_run` and use `secrets: inherit` so DISCORD_CI_WEBHOOK is forwarded.
# Reusable workflow. Callers pass the failed workflow run context via `on: workflow_run`
# and forward DISCORD_CI_WEBHOOK explicitly.
#
# Caller minimum:
# Caller minimum (Gitea):
# on:
# workflow_run:
# workflows: ["*"]
# workflows: ["CI"] # names of the workflows to watch
# types: [completed]
# permissions:
# contents: read
# actions: read
# jobs:
# notify:
# uses: poli0981/.github/.github/workflows/notify-ci-failure.yml@main
# secrets: inherit
# uses: poli0981/.github/.gitea/workflows/notify-ci-failure.yml@<full-sha> # ops vYYYY.MM.N
# with:
# default_branch: main
# secrets: # explicit; `secrets: inherit` is VERIFY on Gitea
# DISCORD_CI_WEBHOOK: ${{ secrets.DISCORD_CI_WEBHOOK }}
#
# Gitea port 2026-11-23:
# - VERIFY: `workflow_run` triggers and the github.event.workflow_run.* payload on Gitea 28.
# - github.event.repository.default_branch → explicit input `default_branch` (runbook §4.1).
# - VERIFY: the run link built by discord_notify.py ({server_url}/{repo}/actions/runs/{id})
# opens the right run on Gitea.
on:
workflow_call:
@@ -19,9 +31,13 @@ on:
# Optional override — if your repo wants to NOT skip deploy/release/scanner workflows
# (e.g., a tools repo where every fail matters), set this to false.
skip_dedicated_workflows:
description: "Skip workflows that have dedicated notifiers (deploy/release/codeql/dependabot)"
description: "Skip workflows that have dedicated notifiers (deploy/release/security/renovate)"
type: boolean
default: true
default_branch:
description: "Caller repo default branch (Gitea may not populate github.event.repository)"
type: string
default: "main"
secrets:
DISCORD_CI_WEBHOOK:
required: true
@@ -41,6 +57,7 @@ jobs:
(
!contains(github.event.workflow_run.name, 'odeQL') &&
!contains(github.event.workflow_run.name, 'ependabot') &&
!contains(github.event.workflow_run.name, 'enovate') &&
!contains(github.event.workflow_run.name, 'ependency') &&
!contains(github.event.workflow_run.name, 'eploy') &&
!contains(github.event.workflow_run.name, 'ages') &&
@@ -49,18 +66,21 @@ jobs:
)
) &&
(
github.event.workflow_run.head_branch == github.event.repository.default_branch ||
github.event.workflow_run.head_branch == inputs.default_branch ||
github.event.workflow_run.head_branch == 'main' ||
github.event.workflow_run.head_branch == 'master'
)
runs-on: ubuntu-latest
timeout-minutes: 3
permissions:
contents: read
actions: read
steps:
# Reusable workflows can't reference scripts in the CALLER repo via
# checkout@v4 (it would only checkout the org-repo). Solution: clone the
# ops repo (poli0981/.github) explicitly to get the discord_notify.py.
# Reusable workflows can't reference scripts in the CALLER repo via checkout
# (it would only check out the caller). Solution: clone the ops repo
# (poli0981/.github) explicitly to get discord_notify.py.
- name: Fetch notifier script from ops repo
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: poli0981/.github
ref: main
@@ -81,4 +101,4 @@ jobs:
COMMIT_MESSAGE: ${{ github.event.workflow_run.head_commit.message }}
ACTOR: ${{ github.event.workflow_run.actor.login }}
EVENT_NAME: ${{ github.event.workflow_run.event }}
run: python ops/.github/scripts/discord_notify.py failure
run: python3 ops/.github/scripts/discord_notify.py failure
@@ -1,7 +1,38 @@
name: Reusable — Notify Deploy Status to Discord
# Reusable. Caller minimum (Gitea):
# on:
# workflow_run:
# workflows: ["Deploy"]
# types: [completed]
# permissions:
# contents: read
# actions: read
# jobs:
# notify:
# uses: poli0981/.github/.gitea/workflows/notify-deploy.yml@<full-sha> # ops vYYYY.MM.N
# with:
# deploy_url: https://example.poli0981.dev # live site shown on success (optional)
# secrets:
# DISCORD_CI_WEBHOOK: ${{ secrets.DISCORD_CI_WEBHOOK }}
#
# Gitea port 2026-11-23:
# - The GitHub Pages lookup (`gh api repos/.../pages`) is removed — Pages does not exist on
# Gitea and sites deploy to Cloudflare Workers. Pass the live URL with `deploy_url`.
# - github.event.repository.default_branch → explicit input `default_branch` (runbook §4.1).
# - VERIFY: `workflow_run` triggers and payload on Gitea 28.
on:
workflow_call:
inputs:
deploy_url:
description: "Live site URL shown on success (optional)"
type: string
default: ""
default_branch:
description: "Caller repo default branch (Gitea may not populate github.event.repository)"
type: string
default: "main"
secrets:
DISCORD_CI_WEBHOOK:
required: true
@@ -22,16 +53,20 @@ jobs:
!startsWith(github.event.workflow_run.name, 'Notify') &&
!contains(github.event.workflow_run.name, 'odeQL') &&
!contains(github.event.workflow_run.name, 'ependabot') &&
!contains(github.event.workflow_run.name, 'enovate') &&
(
github.event.workflow_run.head_branch == github.event.repository.default_branch ||
github.event.workflow_run.head_branch == inputs.default_branch ||
github.event.workflow_run.head_branch == 'main' ||
github.event.workflow_run.head_branch == 'master'
)
runs-on: ubuntu-latest
timeout-minutes: 3
permissions:
contents: read
actions: read
steps:
- name: Fetch notifier script from ops repo
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: poli0981/.github
ref: main
@@ -40,26 +75,16 @@ jobs:
.github/scripts
sparse-checkout-cone-mode: false
- name: Resolve deploy URL
id: site
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STATUS: ${{ github.event.workflow_run.conclusion }}
run: |
DEPLOY_URL=""
if [ "$STATUS" = "success" ]; then
DEPLOY_URL=$(gh api "repos/${GITHUB_REPOSITORY}/pages" --jq '.html_url' 2>/dev/null || echo "")
fi
echo "deploy_url=$DEPLOY_URL" >> "$GITHUB_OUTPUT"
- name: Detect deploy target from workflow name
id: target
env:
WF_NAME: ${{ github.event.workflow_run.name }}
run: |
TARGET="Deploy"
if echo "$WF_NAME" | grep -qiE 'page'; then TARGET="GitHub Pages"; fi
if echo "$WF_NAME" | grep -qiE 'cloudflare'; then TARGET="Cloudflare Pages"; fi
# Later matches win. No GitHub Pages on Gitea; sites deploy to Cloudflare Workers.
if echo "$WF_NAME" | grep -qiE 'cloudflare'; then TARGET="Cloudflare Workers"; fi
if echo "$WF_NAME" | grep -qiE 'page'; then TARGET="Cloudflare Pages"; fi
if echo "$WF_NAME" | grep -qiE 'worker'; then TARGET="Cloudflare Workers"; fi
if echo "$WF_NAME" | grep -qiE 'netlify'; then TARGET="Netlify"; fi
if echo "$WF_NAME" | grep -qiE 'vercel'; then TARGET="Vercel"; fi
echo "target=$TARGET" >> "$GITHUB_OUTPUT"
@@ -69,7 +94,7 @@ jobs:
DISCORD_CI_WEBHOOK: ${{ secrets.DISCORD_CI_WEBHOOK }}
DEPLOY_STATUS: ${{ github.event.workflow_run.conclusion }}
DEPLOY_TARGET: ${{ steps.target.outputs.target }}
DEPLOY_URL: ${{ steps.site.outputs.deploy_url }}
DEPLOY_URL: ${{ github.event.workflow_run.conclusion == 'success' && inputs.deploy_url || '' }}
WORKFLOW_NAME: ${{ github.event.workflow_run.name }}
RUN_ID: ${{ github.event.workflow_run.id }}
RUN_NUMBER: ${{ github.event.workflow_run.run_number }}
@@ -77,4 +102,4 @@ jobs:
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
COMMIT_MESSAGE: ${{ github.event.workflow_run.head_commit.message }}
ACTOR: ${{ github.event.workflow_run.actor.login }}
run: python ops/.github/scripts/discord_notify.py deploy
run: python3 ops/.github/scripts/discord_notify.py deploy
@@ -1,5 +1,22 @@
name: Reusable — Notify Release Pipeline to Discord
# Reusable. Caller minimum (Gitea):
# on:
# workflow_run:
# workflows: ["Release"]
# types: [completed]
# permissions:
# contents: read
# actions: read
# jobs:
# notify:
# uses: poli0981/.github/.gitea/workflows/notify-release-pipeline.yml@<full-sha> # ops vYYYY.MM.N
# secrets:
# DISCORD_RELEASE_PIPELINE_WEBHOOK: ${{ secrets.DISCORD_RELEASE_PIPELINE_WEBHOOK }}
#
# Gitea port 2026-11-23: VERIFY `workflow_run` triggers on Gitea 28 and that head_branch
# carries the tag name (v*) for tag-push runs, as on GitHub.
on:
workflow_call:
secrets:
@@ -34,9 +51,12 @@ jobs:
)
runs-on: ubuntu-latest
timeout-minutes: 3
permissions:
contents: read
actions: read
steps:
- name: Fetch notifier script from ops repo
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: poli0981/.github
ref: main
@@ -71,4 +91,4 @@ jobs:
RELEASE_TAG: ${{ github.event.workflow_run.head_branch }}
WORKFLOW_NAME: ${{ github.event.workflow_run.name }}
RUN_ID: ${{ github.event.workflow_run.id }}
run: python ops/.github/scripts/discord_notify.py release-build
run: python3 ops/.github/scripts/discord_notify.py release-build
+324
View File
@@ -0,0 +1,324 @@
# Reusable: upload release files to Cloudflare R2 (runbook §4.4)
#
# Bucket `poli0981-releases`, public ONLY through https://releases.poli0981.dev/<app>/
# (r2.dev disabled, no directory listing — link exact files). For uploads that
# `vpk upload s3` does not do: Tauri bundles + latest.json, extension zips, other files.
#
# Lives in poli0981/.github (Gitea) → called via:
# jobs:
# build:
# ... # stage the files, then upload ONE artifact:
# - uses: christopherhx/gitea-upload-artifact@<sha> # v4
# with: { name: r2-release, path: r2-release/ }
# publish:
# needs: build
# if: startsWith(github.ref, 'refs/tags/v')
# permissions:
# contents: read
# uses: poli0981/.github/.gitea/workflows/publish-r2.yml@<full-sha> # ops vYYYY.MM.N
# with:
# app: pipdock # folder under the bucket = repo name, lowercase
# artifact: r2-release
# versioned-dir: versioned # its CONTENTS go to <app>/: versioned/1.4.0/x.exe → <app>/1.4.0/x.exe
# feed-files: | # each file → <app>/<file name>, uploaded LAST
# latest.json
# secrets:
# R2_RELEASES_ACCESS_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
# R2_RELEASES_SECRET_ACCESS_KEY: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
#
# All paths are relative to the root of the downloaded artifact.
# Needs: user-level Actions variable R2_ACCOUNT_ID; secrets R2_RELEASES_ACCESS_KEY_ID /
# R2_RELEASES_SECRET_ACCESS_KEY (R2 API token: Object Read & Write on poli0981-releases only).
#
# Guarantees:
# - versioned files: `rclone copy --immutable --checksum` → an existing object is never
# overwritten with different content (a re-run with identical files is a no-op);
# never `sync`, never `delete`
# - feed files: uploaded after ALL versioned files (`rclone copyto`); their names must be
# on the Cloudflare cache-bypass list (runbook §1), otherwise the edge could serve a
# stale feed — the job fails before uploading anything
# - rclone pinned + SHA-256 verified; configured only through env vars, with an empty
# config file so the host-mode Windows runner never picks up a local rclone.conf
# - runs only for tag pushes (refs/tags/v*) or workflow_dispatch (runbook §2 rule 10)
name: Reusable / Publish to R2
on:
workflow_call:
inputs:
app:
description: 'Folder under the bucket (= repo name, lowercase): releases.poli0981.dev/<app>/'
type: string
required: true
artifact:
description: 'Name of the workflow artifact (same run) that holds the files'
type: string
default: 'r2-release'
versioned-dir:
description: 'Directory inside the artifact whose contents are uploaded first; every file name must contain the version'
type: string
required: true
feed-files:
description: 'Newline-separated files inside the artifact, uploaded last to <app>/<file name> (e.g. latest.json)'
type: string
default: ''
runs-on:
description: "'windows-latest' (host mode on the maintainer PC) | 'ubuntu-latest' (Docker)"
type: string
default: 'windows-latest'
secrets:
R2_RELEASES_ACCESS_KEY_ID:
required: true
R2_RELEASES_SECRET_ACCESS_KEY:
required: true
outputs:
base-url:
description: 'Public base URL: https://releases.poli0981.dev/<app>'
value: ${{ jobs.publish.outputs.base-url }}
permissions:
contents: read
jobs:
publish:
# Release credentials: tag pushes or manual runs only (runbook §2 rule 10)
if: ${{ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || github.event_name == 'workflow_dispatch' }}
runs-on: ${{ inputs.runs-on }}
timeout-minutes: 30
permissions:
contents: read
concurrency:
group: publish-r2-${{ inputs.app }}
cancel-in-progress: false
outputs:
base-url: ${{ steps.prep-win.outputs.base-url || steps.prep-linux.outputs.base-url }}
env:
APP: ${{ inputs.app }}
VERSIONED_DIR: ${{ inputs.versioned-dir }}
FEED_FILES: ${{ inputs.feed-files }}
R2_ACCOUNT_ID: ${{ vars.R2_ACCOUNT_ID }}
R2_BUCKET: poli0981-releases
PUBLIC_BASE: https://releases.poli0981.dev
ARTIFACT_DIR: _r2
RCLONE_VERSION: v1.76.0
RCLONE_SHA256_WINDOWS: 8b4fd2737ade4e70c057ef4a49deb7cffe94b0fb9d7587c189d149823f21a1dc # rclone-v1.76.0-windows-amd64.zip
RCLONE_SHA256_LINUX: b00f00b3266c3764413afe599d3ec316f6f43b3e0ea8a0bc1d186d2133e46df7 # rclone-v1.76.0-linux-amd64.zip
# rclone remote "r2" — env-only config, same scheme as the server backup script.
# The access keys are added only on the upload steps.
RCLONE_CONFIG_R2_TYPE: s3
RCLONE_CONFIG_R2_PROVIDER: Cloudflare
RCLONE_CONFIG_R2_ENDPOINT: https://${{ vars.R2_ACCOUNT_ID }}.r2.cloudflarestorage.com
RCLONE_CONFIG_R2_REGION: auto
RCLONE_CONFIG_R2_NO_CHECK_BUCKET: 'true'
steps:
- name: Download release files (artifact ${{ inputs.artifact }})
uses: christopherhx/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7 # v4
with:
name: ${{ inputs.artifact }}
path: ${{ env.ARTIFACT_DIR }}
# ---------------- Windows (host mode, PowerShell) ----------------
- name: Validate + install rclone (Windows)
id: prep-win
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
function Fail([string]$msg) { Write-Host "::error::$msg"; exit 1 }
function Test-RelPath([string]$p) { -not ([IO.Path]::IsPathRooted($p) -or $p -match '(^|[\\/])\.\.([\\/]|$)') }
if ($env:APP -cnotmatch '^[a-z0-9][a-z0-9._-]*$' -or $env:APP.Contains('..')) { Fail "app '$($env:APP)' must be the lowercase repo name ([a-z0-9._-])" }
if ($env:R2_ACCOUNT_ID -notmatch '^[0-9a-f]{32}$') { Fail 'Actions variable R2_ACCOUNT_ID is missing or not a 32-hex Cloudflare account ID' }
$root = (Resolve-Path -LiteralPath $env:ARTIFACT_DIR).Path
$vdir = $env:VERSIONED_DIR.Trim()
if (-not $vdir -or -not (Test-RelPath $vdir)) { Fail "versioned-dir '$vdir' must be a relative path inside the artifact" }
$vpath = Join-Path $root $vdir
if (-not (Test-Path -LiteralPath $vpath -PathType Container)) { Fail "versioned-dir '$vdir' not found in the artifact" }
$vfull = (Resolve-Path -LiteralPath $vpath).Path.TrimEnd('\', '/') + [IO.Path]::DirectorySeparatorChar
$vfiles = @(Get-ChildItem -LiteralPath $vpath -Recurse -File)
if ($vfiles.Count -eq 0) { Fail "versioned-dir '$vdir' is empty" }
# Cloudflare cache-bypass names (runbook §1 "Release caching")
$bypass = @('*.json', 'RELEASES', '*-Setup.exe', '*-Setup.pkg', '*-Portable.zip', '*.AppImage', '*-latest.*')
$feeds = @($env:FEED_FILES -split "`r?`n" | ForEach-Object { $_.Trim() } | Where-Object { $_ })
$seen = @{}
foreach ($f in $feeds) {
if (-not (Test-RelPath $f)) { Fail "feed file '$f' must be a relative path inside the artifact" }
$fp = Join-Path $root $f
if (-not (Test-Path -LiteralPath $fp -PathType Leaf)) { Fail "feed file '$f' not found in the artifact" }
if ((Resolve-Path -LiteralPath $fp).Path.StartsWith($vfull, [StringComparison]::OrdinalIgnoreCase)) { Fail "feed file '$f' is inside versioned-dir; feeds are uploaded separately, last" }
$name = Split-Path -Leaf $f
if (-not ($bypass | Where-Object { $name -clike $_ })) { Fail "feed file '$name' is not on the cache-bypass list ($($bypass -join ', ')); the edge would cache it" }
if ($seen.ContainsKey($name)) { Fail "two feed files share the name '$name'" }
$seen[$name] = $true
}
Write-Host "Versioned files ($($vfiles.Count)) -> $($env:R2_BUCKET)/$($env:APP)/"
$vfiles | ForEach-Object { Write-Host " $($_.FullName.Substring($vfull.Length))" }
Write-Host "Feed files ($($feeds.Count)) -> uploaded last: $($seen.Keys -join ', ')"
$tmp = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { [IO.Path]::GetTempPath() }
$pkg = "rclone-$($env:RCLONE_VERSION)-windows-amd64"
$zip = Join-Path $tmp "$pkg.zip"
Invoke-WebRequest -UseBasicParsing -Uri "https://downloads.rclone.org/$($env:RCLONE_VERSION)/$pkg.zip" -OutFile $zip
$hash = (Get-FileHash -Algorithm SHA256 -LiteralPath $zip).Hash.ToLowerInvariant()
if ($hash -ne $env:RCLONE_SHA256_WINDOWS) { Fail "rclone checksum mismatch: $hash" }
$dest = Join-Path $tmp 'rclone'
Expand-Archive -LiteralPath $zip -DestinationPath $dest -Force
$bin = Join-Path $dest $pkg
& (Join-Path $bin 'rclone.exe') version
if ($LASTEXITCODE) { Fail 'rclone does not run' }
$bin >> $env:GITHUB_PATH
# Empty config file: never read a local rclone.conf on the host-mode runner
$cfg = Join-Path $tmp 'rclone-empty.conf'
Set-Content -LiteralPath $cfg -Value '' -NoNewline
"RCLONE_CONFIG=$cfg" >> $env:GITHUB_ENV
"base-url=$($env:PUBLIC_BASE)/$($env:APP)" >> $env:GITHUB_OUTPUT
- name: Upload — versioned files first, feeds last (Windows)
if: ${{ runner.os == 'Windows' }}
shell: pwsh
env:
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
run: |
$ErrorActionPreference = 'Stop'
$root = (Resolve-Path -LiteralPath $env:ARTIFACT_DIR).Path
$dest = "r2:$($env:R2_BUCKET)/$($env:APP)"
rclone copy --immutable --checksum --stats-one-line -v (Join-Path $root $env:VERSIONED_DIR.Trim()) "$dest/"
if ($LASTEXITCODE) { Write-Host '::error::Versioned upload failed (an existing object with different content is never overwritten)'; exit $LASTEXITCODE }
foreach ($f in @($env:FEED_FILES -split "`r?`n" | ForEach-Object { $_.Trim() } | Where-Object { $_ })) {
rclone copyto --checksum -v (Join-Path $root $f) "$dest/$(Split-Path -Leaf $f)"
if ($LASTEXITCODE) { Write-Host "::error::Feed upload failed: $f"; exit $LASTEXITCODE }
}
- name: Smoke test public URLs (Windows)
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$base = "$($env:PUBLIC_BASE)/$($env:APP)"
$feeds = @($env:FEED_FILES -split "`r?`n" | ForEach-Object { $_.Trim() } | Where-Object { $_ })
if ($feeds.Count) {
$paths = @($feeds | ForEach-Object { Split-Path -Leaf $_ })
} else {
$vpath = (Resolve-Path -LiteralPath (Join-Path $env:ARTIFACT_DIR $env:VERSIONED_DIR.Trim())).Path.TrimEnd('\', '/')
$first = Get-ChildItem -LiteralPath $vpath -Recurse -File | Sort-Object FullName | Select-Object -First 1
$paths = @($first.FullName.Substring($vpath.Length + 1) -replace '\\', '/')
}
foreach ($p in $paths) {
$url = "$base/" + (($p -split '/' | ForEach-Object { [Uri]::EscapeDataString($_) }) -join '/')
$code = curl.exe -sS -o NUL -I -w '%{http_code}' --retry 3 --retry-all-errors $url
Write-Host "HEAD $url -> $code"
if ($code -ne '200') { Write-Host "::error::Smoke test failed: $url"; exit 1 }
}
# ---------------- Linux (Docker) ----------------
- name: Validate + install rclone (Linux)
id: prep-linux
if: ${{ runner.os != 'Windows' }}
shell: bash
run: |
set -euo pipefail
fail() { echo "::error::$*"; exit 1; }
trim() { local s="$1"; s="${s#"${s%%[![:space:]]*}"}"; s="${s%"${s##*[![:space:]]}"}"; printf '%s' "$s"; }
dotdot='(^|/)\.\.(/|$)'
relpath_ok() { [[ -n "$1" && "$1" != /* && ! "$1" =~ $dotdot ]]; }
[[ "$APP" =~ ^[a-z0-9][a-z0-9._-]*$ && "$APP" != *..* ]] || fail "app '$APP' must be the lowercase repo name ([a-z0-9._-])"
[[ "$R2_ACCOUNT_ID" =~ ^[0-9a-fA-F]{32}$ ]] || fail "Actions variable R2_ACCOUNT_ID is missing or not a 32-hex Cloudflare account ID"
cd "$ARTIFACT_DIR"
vdir="$(trim "$VERSIONED_DIR")"
relpath_ok "$vdir" || fail "versioned-dir '$vdir' must be a relative path inside the artifact"
[ -d "$vdir" ] || fail "versioned-dir '$vdir' not found in the artifact"
vreal="$(realpath "$vdir")"
count="$(find "$vdir" -type f | wc -l)"
[ "$count" -gt 0 ] || fail "versioned-dir '$vdir' is empty"
declare -A seen=()
nfeeds=0
while IFS= read -r f; do
f="$(trim "$f")"; [ -n "$f" ] || continue
relpath_ok "$f" || fail "feed file '$f' must be a relative path inside the artifact"
[ -f "$f" ] || fail "feed file '$f' not found in the artifact"
case "$(realpath "$f")" in "$vreal"/*) fail "feed file '$f' is inside versioned-dir; feeds are uploaded separately, last" ;; esac
name="$(basename "$f")"
# Cloudflare cache-bypass names (runbook §1 "Release caching")
case "$name" in
*.json|RELEASES|*-Setup.exe|*-Setup.pkg|*-Portable.zip|*.AppImage|*-latest.*) ;;
*) fail "feed file '$name' is not on the cache-bypass list; the edge would cache it" ;;
esac
[ -z "${seen[$name]:-}" ] || fail "two feed files share the name '$name'"
seen[$name]=1; nfeeds=$((nfeeds + 1))
done < <(printf '%s\n' "$FEED_FILES" | tr -d '\r')
echo "Versioned files ($count) -> ${R2_BUCKET}/${APP}/"
(cd "$vdir" && find . -type f | sed 's#^\./# #' | sort)
echo "Feed files ($nfeeds) -> uploaded last: ${!seen[*]}"
tmp="${RUNNER_TEMP:-/tmp}"
pkg="rclone-${RCLONE_VERSION}-linux-amd64"
curl -fsSL --retry 3 -o "$tmp/$pkg.zip" "https://downloads.rclone.org/${RCLONE_VERSION}/$pkg.zip"
echo "${RCLONE_SHA256_LINUX} $tmp/$pkg.zip" | sha256sum -c -
if command -v unzip >/dev/null 2>&1; then
unzip -q -o "$tmp/$pkg.zip" -d "$tmp"
else
python3 -m zipfile -e "$tmp/$pkg.zip" "$tmp"
fi
chmod +x "$tmp/$pkg/rclone"
"$tmp/$pkg/rclone" version
echo "$tmp/$pkg" >> "$GITHUB_PATH"
: > "$tmp/rclone-empty.conf"
echo "RCLONE_CONFIG=$tmp/rclone-empty.conf" >> "$GITHUB_ENV"
echo "base-url=${PUBLIC_BASE}/${APP}" >> "$GITHUB_OUTPUT"
- name: Upload — versioned files first, feeds last (Linux)
if: ${{ runner.os != 'Windows' }}
shell: bash
env:
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
run: |
set -euo pipefail
trim() { local s="$1"; s="${s#"${s%%[![:space:]]*}"}"; s="${s%"${s##*[![:space:]]}"}"; printf '%s' "$s"; }
cd "$ARTIFACT_DIR"
dest="r2:${R2_BUCKET}/${APP}"
rclone copy --immutable --checksum --stats-one-line -v "$(trim "$VERSIONED_DIR")" "$dest/" \
|| { echo "::error::Versioned upload failed (an existing object with different content is never overwritten)"; exit 1; }
while IFS= read -r f; do
f="$(trim "$f")"; [ -n "$f" ] || continue
rclone copyto --checksum -v "$f" "$dest/$(basename "$f")" \
|| { echo "::error::Feed upload failed: $f"; exit 1; }
done < <(printf '%s\n' "$FEED_FILES" | tr -d '\r')
- name: Smoke test public URLs (Linux)
if: ${{ runner.os != 'Windows' }}
shell: bash
run: |
set -euo pipefail
trim() { local s="$1"; s="${s#"${s%%[![:space:]]*}"}"; s="${s%"${s##*[![:space:]]}"}"; printf '%s' "$s"; }
base="${PUBLIC_BASE}/${APP}"
paths=()
while IFS= read -r f; do
f="$(trim "$f")"; [ -n "$f" ] || continue
paths+=("$(basename "$f")")
done < <(printf '%s\n' "$FEED_FILES" | tr -d '\r')
if [ "${#paths[@]}" -eq 0 ]; then
first="$(cd "$ARTIFACT_DIR/$(trim "$VERSIONED_DIR")" && find . -type f | sed 's#^\./##' | LC_ALL=C sort | head -n 1 || true)"
paths+=("$first")
fi
for p in "${paths[@]}"; do
url="$base/$(printf '%s' "$p" | sed 's/ /%20/g')"
code="$(curl -sS -o /dev/null -I -w '%{http_code}' --retry 3 --retry-all-errors "$url" || true)"
echo "HEAD $url -> $code"
[ "$code" = "200" ] || { echo "::error::Smoke test failed: $url"; exit 1; }
done
+79
View File
@@ -0,0 +1,79 @@
# Reusable CI for Assembly projects (x86-64 Linux)
# Make-driven: repo provides a Makefile; workflow installs the assembler and runs it.
# NOTE: no SAST rules / dependency ecosystem for Assembly — this repo type gets CI
# plus the gitleaks job of security.yml.
#
# Lives in poli0981/.github (Gitea) → called via:
# uses: poli0981/.github/.gitea/workflows/reusable-assembly.yml@<full-sha> # ops vYYYY.MM.N
#
# Gitea port 2026-11-23: ubuntu-latest = Docker image docker.gitea.com/runner-images.
# Unlike GitHub-hosted images, binutils/make are not guaranteed there, so they are
# installed when missing (VERIFY on pilot). Actions pinned to commit SHAs (Renovate).
name: Reusable / Assembly
on:
workflow_call:
inputs:
assembler:
description: "'nasm' (installed via apt) | 'gas' (binutils)"
type: string
default: 'nasm'
build-command:
type: string
default: 'make'
run-tests:
type: boolean
default: true
test-command:
type: string
default: 'make test'
jobs:
build-test:
runs-on: ubuntu-latest # Gitea: Docker, docker.gitea.com/runner-images
timeout-minutes: 15
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install toolchain (when missing)
env:
ASSEMBLER: ${{ inputs.assembler }}
run: |
SUDO=""; [ "$(id -u)" -ne 0 ] && SUDO="sudo"
PKGS=""
command -v as >/dev/null 2>&1 || PKGS="$PKGS binutils"
command -v ld >/dev/null 2>&1 || PKGS="$PKGS binutils"
command -v make >/dev/null 2>&1 || PKGS="$PKGS make"
if [ "$ASSEMBLER" = "nasm" ]; then
command -v nasm >/dev/null 2>&1 || PKGS="$PKGS nasm"
fi
if [ -n "$PKGS" ]; then
$SUDO apt-get update -qq
# shellcheck disable=SC2086
$SUDO apt-get install -y -qq $PKGS
fi
- name: Toolchain info
run: |
as --version | head -1
ld --version | head -1
make --version | head -1
if command -v nasm >/dev/null 2>&1; then nasm -v; fi
- name: Build
run: ${{ inputs.build-command }}
- name: Test
if: ${{ inputs.run-tests }}
run: |
if [ "${{ inputs.test-command }}" != "make test" ]; then
${{ inputs.test-command }}
elif make -n test >/dev/null 2>&1; then
make test
else
echo "No test target — skipping"
fi
@@ -1,8 +1,13 @@
# Reusable CI for C / C++ projects (shared by both languages)
# Default: CMake configure/build/ctest across a GCC + Clang matrix.
#
# Verified 2026-07-06: ubuntu-latest = Ubuntu 24.04 (CMake 3.31.6, Clang 16/17/18 preinstalled,
# GCC = Ubuntu 24.04 defaults), checkout v7, upload-artifact v7
# Lives in poli0981/.github (Gitea) → called via:
# uses: poli0981/.github/.gitea/workflows/reusable-c-cpp.yml@<full-sha> # ops vYYYY.MM.N
#
# Gitea port 2026-11-23: ubuntu-latest = Docker image docker.gitea.com/runner-images.
# GitHub-hosted images shipped CMake + Clang preinstalled; the Gitea image may not,
# so missing tools are installed from Ubuntu apt (VERIFY on pilot).
# Actions pinned to commit SHAs (Renovate keeps them current).
name: Reusable / C-C++
@@ -36,7 +41,7 @@ on:
jobs:
build-test:
name: Build (${{ matrix.compiler }})
runs-on: ubuntu-latest # = Ubuntu 24.04 LTS
runs-on: ubuntu-latest # Gitea: Docker, docker.gitea.com/runner-images
timeout-minutes: 30
permissions:
contents: read
@@ -46,7 +51,29 @@ jobs:
compiler: ${{ fromJSON(inputs.compilers) }}
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install toolchain (when missing)
env:
COMPILER: ${{ matrix.compiler }}
BUILD_SYSTEM: ${{ inputs.build-system }}
run: |
SUDO=""; [ "$(id -u)" -ne 0 ] && SUDO="sudo"
PKGS=""
command -v make >/dev/null 2>&1 || PKGS="$PKGS make"
if [ "$COMPILER" = "clang" ]; then
command -v clang >/dev/null 2>&1 || PKGS="$PKGS clang"
else
command -v g++ >/dev/null 2>&1 || PKGS="$PKGS build-essential"
fi
if [ "$BUILD_SYSTEM" = "cmake" ]; then
command -v cmake >/dev/null 2>&1 || PKGS="$PKGS cmake"
fi
if [ -n "$PKGS" ]; then
$SUDO apt-get update -qq
# shellcheck disable=SC2086
$SUDO apt-get install -y -qq $PKGS
fi
- name: Select compiler
run: |
@@ -62,7 +89,7 @@ jobs:
run: |
"$CC" --version | head -1
"$CXX" --version | head -1
cmake --version | head -1
if command -v cmake >/dev/null 2>&1; then cmake --version | head -1; fi
# --- CMake path ---
- name: Configure (CMake)
@@ -0,0 +1,252 @@
# Reusable CI/CD for Chrome extensions (Manifest V3)
# Supports two modes:
# package-manager: 'none' → zero-npm-dependency vanilla extensions (syntax check + zip)
# package-manager: 'npm' | 'pnpm' → built extensions (WXT + Svelte 5 + TS, etc.)
#
# Lives in poli0981/.github (Gitea) → called via:
# uses: poli0981/.github/.gitea/workflows/reusable-chrome-extension.yml@<full-sha> # ops vYYYY.MM.N
#
# Release (tag push v*, runbook §3.3 / §5.4): store submission stays manual; the zip is
# published to https://releases.poli0981.dev/<app>/<version>/<repo>-v<version>.zip through
# publish-r2.yml, then a Gitea release is created with notes + link (no binaries):
# on:
# push:
# tags: ['v*']
# jobs:
# release:
# permissions:
# contents: write
# releases: write
# uses: poli0981/.github/.gitea/workflows/reusable-chrome-extension.yml@<full-sha> # ops vYYYY.MM.N
# with:
# release: true
# package-manager: pnpm
# build-command: pnpm build
# source-dir: .output/chrome-mv3
# secrets:
# R2_RELEASES_ACCESS_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
# R2_RELEASES_SECRET_ACCESS_KEY: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
#
# Gitea port 2026-11-23: ubuntu-latest = Docker image docker.gitea.com/runner-images.
# VERIFY on pilot: the nested call `uses: ./.gitea/workflows/publish-r2.yml` must resolve to
# this ops repo at the same commit. If Gitea resolves `./` against the CALLER repo, change it
# to `poli0981/.github/.gitea/workflows/publish-r2.yml@<sha of the same ops tag>`.
# Actions pinned to commit SHAs (Renovate keeps them current).
name: Reusable / Chrome Extension
on:
workflow_call:
inputs:
package-manager:
description: "'none' (vanilla, zero deps) | 'npm' | 'pnpm'"
type: string
default: 'none'
node-version:
type: string
default: '24' # Node 24 = active LTS
build-command:
description: 'Build command when package-manager != none'
type: string
default: 'npm run build'
source-dir:
description: 'Directory containing manifest.json to package (vanilla: ".", WXT: ".output/chrome-mv3")'
type: string
default: '.'
release:
description: 'true = publish the zip to releases.poli0981.dev + Gitea release notes (call from a tag workflow)'
type: boolean
default: false
app:
description: 'Folder under releases.poli0981.dev (empty = repo name, lowercase)'
type: string
default: ''
secrets:
R2_RELEASES_ACCESS_KEY_ID:
required: false # only for release: true
R2_RELEASES_SECRET_ACCESS_KEY:
required: false
jobs:
build:
if: ${{ !inputs.release }}
runs-on: ubuntu-latest # Gitea: Docker, docker.gitea.com/runner-images
timeout-minutes: 15
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup pnpm
if: ${{ inputs.package-manager == 'pnpm' }}
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- name: Setup Node.js ${{ inputs.node-version }}
if: ${{ inputs.package-manager != 'none' }}
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: ${{ inputs.node-version }}
cache: ${{ inputs.package-manager }}
- name: Install dependencies
if: ${{ inputs.package-manager != 'none' }}
run: |
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm install --frozen-lockfile
else
npm ci
fi
- name: Build
if: ${{ inputs.package-manager != 'none' }}
run: ${{ inputs.build-command }}
- name: Syntax-check vanilla JS modules
if: ${{ inputs.package-manager == 'none' }}
run: |
find "${{ inputs.source-dir }}" -name '*.js' \
-not -path '*/node_modules/*' -not -path '*/.git/*' -print0 \
| xargs -0 -r -n1 node --check
echo "All JS files pass syntax check"
- name: Validate MV3 manifest
run: |
MANIFEST="${{ inputs.source-dir }}/manifest.json"
test -f "$MANIFEST" || { echo "::error::manifest.json not found in ${{ inputs.source-dir }}"; exit 1; }
jq -e '.manifest_version == 3' "$MANIFEST" > /dev/null || { echo "::error::manifest_version must be 3"; exit 1; }
echo "Extension version: $(jq -r '.version' "$MANIFEST")"
- name: Package zip
id: pack
run: |
MANIFEST="${{ inputs.source-dir }}/manifest.json"
VERSION=$(jq -r '.version' "$MANIFEST")
NAME="${GITHUB_REPOSITORY##*/}"
ZIP="${NAME}-v${VERSION}.zip"
(cd "${{ inputs.source-dir }}" && zip -rq "$GITHUB_WORKSPACE/$ZIP" . \
-x '.git/*' -x '.github/*' -x '.gitea/*' -x '.gitlab/*' -x 'node_modules/*' -x 'docs/*' -x '*.zip' -x '*.map')
echo "zip=$ZIP" >> "$GITHUB_OUTPUT"
- name: Upload artifact
uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
name: extension-zip
path: ${{ steps.pack.outputs.zip }}
retention-days: 14
package:
# Release credentials downstream: tag pushes (or a manual run on a tag) only — runbook §2 rule 10
if: ${{ inputs.release && startsWith(github.ref, 'refs/tags/v') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
outputs:
app: ${{ steps.pack.outputs.app }}
version: ${{ steps.pack.outputs.version }}
zip: ${{ steps.pack.outputs.zip }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup pnpm
if: ${{ inputs.package-manager == 'pnpm' }}
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- name: Setup Node.js ${{ inputs.node-version }}
if: ${{ inputs.package-manager != 'none' }}
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: ${{ inputs.node-version }}
cache: ${{ inputs.package-manager }}
- name: Install + build
if: ${{ inputs.package-manager != 'none' }}
run: |
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm install --frozen-lockfile
else
npm ci
fi
${{ inputs.build-command }}
- name: Package zip (versioned path for R2)
id: pack
env:
APP_INPUT: ${{ inputs.app }}
run: |
set -euo pipefail
MANIFEST="${{ inputs.source-dir }}/manifest.json"
VERSION=$(jq -r '.version' "$MANIFEST")
[[ "$VERSION" =~ ^[0-9]+(\.[0-9]+){0,3}$ ]] || { echo "::error::manifest version '$VERSION' is not a Chrome version"; exit 1; }
TAG="${GITHUB_REF_NAME#v}"
if [ "$TAG" != "$VERSION" ]; then
echo "::warning::Tag ($TAG) != manifest version ($VERSION)"
fi
NAME="${GITHUB_REPOSITORY##*/}"
APP="${APP_INPUT:-$NAME}"
APP="$(printf '%s' "$APP" | tr '[:upper:]' '[:lower:]')"
ZIP="${NAME}-v${VERSION}.zip"
(cd "${{ inputs.source-dir }}" && zip -rq "$GITHUB_WORKSPACE/$ZIP" . \
-x '.git/*' -x '.github/*' -x '.gitea/*' -x '.gitlab/*' -x 'node_modules/*' -x 'docs/*' -x '*.zip' -x '*.map')
mkdir -p "r2-release/versioned/$VERSION"
mv "$ZIP" "r2-release/versioned/$VERSION/"
{
echo "app=$APP"
echo "version=$VERSION"
echo "zip=$ZIP"
} >> "$GITHUB_OUTPUT"
- name: Upload release files for publish-r2
uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
name: r2-release
path: r2-release/
if-no-files-found: error
retention-days: 7
publish:
needs: package
if: ${{ inputs.release && startsWith(github.ref, 'refs/tags/v') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
permissions:
contents: read
uses: ./.gitea/workflows/publish-r2.yml # VERIFY: resolves to this ops repo (see header)
with:
app: ${{ needs.package.outputs.app }}
artifact: r2-release
versioned-dir: versioned
runs-on: ubuntu-latest
secrets:
R2_RELEASES_ACCESS_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
R2_RELEASES_SECRET_ACCESS_KEY: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
gitea-release:
needs: [package, publish]
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write # Gitea release (VERIFY which of contents/releases Gitea enforces)
releases: write
steps:
- name: Write release notes (links only)
env:
APP: ${{ needs.package.outputs.app }}
VERSION: ${{ needs.package.outputs.version }}
ZIP: ${{ needs.package.outputs.zip }}
run: |
URL="https://releases.poli0981.dev/${APP}/${VERSION}/${ZIP}"
{
echo "${GITHUB_REPOSITORY##*/} ${VERSION}"
echo
echo "**Extension package:** [${ZIP}](${URL})"
echo
echo "Install from the Chrome Web Store listing; the zip is for manual loading and archiving."
} > release-notes.md
cat release-notes.md
- name: Create Gitea release (notes + link, no binaries)
uses: https://gitea.com/actions/gitea-release-action@5a83c90484ef4355121df5eb60558c8ce66e81ac # v1.3.7
with:
tag_name: ${{ github.ref_name }}
body_path: release-notes.md
@@ -0,0 +1,273 @@
# Reusable CI/CD for Windows desktop apps (.NET 10 LTS / WPF / Velopack)
# Lives in poli0981/.github (Gitea) → called via:
# uses: poli0981/.github/.gitea/workflows/reusable-desktop-csharp.yml@<full-sha> # ops vYYYY.MM.N
#
# Build + test (push / pull_request):
# jobs:
# ci:
# permissions:
# contents: read
# uses: poli0981/.github/.gitea/workflows/reusable-desktop-csharp.yml@<full-sha> # ops vYYYY.MM.N
# with:
# solution: MyApp.sln
#
# Release (tag push v*, runbook §5.1) → Velopack feed + installers on
# https://releases.poli0981.dev/<app>/ and a Gitea release with notes + links (no binaries):
# on:
# push:
# tags: ['v*']
# jobs:
# release:
# permissions:
# contents: write
# releases: write
# uses: poli0981/.github/.gitea/workflows/reusable-desktop-csharp.yml@<full-sha> # ops vYYYY.MM.N
# with:
# release: true
# project: src/MyApp/MyApp.csproj
# pack-id: MyApp
# secrets:
# R2_RELEASES_ACCESS_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
# R2_RELEASES_SECRET_ACCESS_KEY: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
#
# Gitea port 2026-11-23:
# - windows-latest = HOST MODE on the maintainer PC (PowerShell, no isolation). setup-dotnet
# installs into the runner tool cache (DOTNET_INSTALL_DIR) instead of C:\Program Files\dotnet,
# and vpk goes to a per-job --tool-path: nothing is installed system-wide.
# - Releases use `vpk download/upload s3` against R2 (bucket poli0981-releases, prefix <app>/);
# credentials only through VPK_* env vars, never on the command line.
# VERIFY on pilot: R2 works with --endpoint only (add --region auto if signing fails), the
# objects land under <app>/, and Setup.exe / Portable.zip are uploaded with the feed.
# - App code: new UpdateManager("https://releases.poli0981.dev/<app>") (HTTP source; no GithubSource).
# - Installs that update from GitHub Releases cannot be redirected from here (runbook §7 item 5).
# - Needs: user-level variable R2_ACCOUNT_ID + secrets R2_RELEASES_ACCESS_KEY_ID / _SECRET_ACCESS_KEY.
name: Reusable / Desktop C#
on:
workflow_call:
inputs:
solution:
description: 'Path to .sln (empty = auto-detect single solution in root)'
type: string
default: ''
project:
description: 'Main .csproj used for publish + Velopack pack (release only)'
type: string
default: ''
dotnet-version:
description: '.NET SDK version'
type: string
default: '10.0.x' # .NET 10 = current LTS (Nov 2025 → Nov 2028)
configuration:
type: string
default: 'Release'
rid:
description: 'Runtime identifier for publish'
type: string
default: 'win-x64'
run-tests:
type: boolean
default: true
release:
description: 'true = publish + vpk pack + upload to R2 + Gitea release notes (call from a tag workflow)'
type: boolean
default: false
pack-id:
description: 'Velopack packId (required when release: true)'
type: string
default: ''
main-exe:
description: 'Main exe name; defaults to <pack-id>.exe'
type: string
default: ''
app:
description: 'Folder under releases.poli0981.dev (empty = repo name, lowercase)'
type: string
default: ''
vpk-version:
description: 'Velopack CLI version; keep it equal to the Velopack NuGet package of the app'
type: string
default: '1.2.161'
secrets:
R2_RELEASES_ACCESS_KEY_ID:
required: false # only for release: true
R2_RELEASES_SECRET_ACCESS_KEY:
required: false
jobs:
build-test:
if: ${{ !inputs.release }}
runs-on: windows-latest # Gitea: host mode on the maintainer PC (PowerShell)
timeout-minutes: 30
permissions:
contents: read
env:
DOTNET_CLI_TELEMETRY_OPTOUT: '1'
DOTNET_NOLOGO: '1'
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Keep .NET SDK installs in the runner tool cache (host mode)
shell: pwsh
run: |
$base = if ($env:RUNNER_TOOL_CACHE) { $env:RUNNER_TOOL_CACHE } else { Join-Path $env:LOCALAPPDATA 'gitea-runner\toolcache' }
"DOTNET_INSTALL_DIR=$(Join-Path $base 'dotnet')" >> $env:GITHUB_ENV
- name: Setup .NET ${{ inputs.dotnet-version }}
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0
with:
dotnet-version: ${{ inputs.dotnet-version }}
- name: Restore
run: dotnet restore ${{ inputs.solution }}
- name: Build
run: dotnet build ${{ inputs.solution }} --configuration ${{ inputs.configuration }} --no-restore
- name: Test
if: ${{ inputs.run-tests }}
run: dotnet test ${{ inputs.solution }} --configuration ${{ inputs.configuration }} --no-build --logger "trx;LogFileName=test-results.trx"
- name: Upload test results
if: ${{ inputs.run-tests && always() }}
uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
name: test-results
path: '**/TestResults/*.trx'
if-no-files-found: ignore
retention-days: 14
release:
# Release credentials: tag pushes (or a manual run on a tag) only — runbook §2 rule 10
if: ${{ inputs.release && startsWith(github.ref, 'refs/tags/v') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
runs-on: windows-latest # Gitea: host mode on the maintainer PC (PowerShell)
timeout-minutes: 45
permissions:
contents: write # Gitea release (VERIFY which of contents/releases Gitea enforces)
releases: write
env:
DOTNET_CLI_TELEMETRY_OPTOUT: '1'
DOTNET_NOLOGO: '1'
VPK_BUCKET: poli0981-releases
VPK_ENDPOINT: https://${{ vars.R2_ACCOUNT_ID }}.r2.cloudflarestorage.com
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Keep .NET SDK installs in the runner tool cache (host mode)
shell: pwsh
run: |
$base = if ($env:RUNNER_TOOL_CACHE) { $env:RUNNER_TOOL_CACHE } else { Join-Path $env:LOCALAPPDATA 'gitea-runner\toolcache' }
"DOTNET_INSTALL_DIR=$(Join-Path $base 'dotnet')" >> $env:GITHUB_ENV
- name: Setup .NET ${{ inputs.dotnet-version }}
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0
with:
dotnet-version: ${{ inputs.dotnet-version }}
- name: Resolve version + app from tag
id: ver
shell: pwsh
env:
APP_INPUT: ${{ inputs.app }}
PACK_ID: ${{ inputs.pack-id }}
R2_ACCOUNT_ID: ${{ vars.R2_ACCOUNT_ID }}
run: |
function Fail([string]$msg) { Write-Host "::error::$msg"; exit 1 }
$v = $env:GITHUB_REF_NAME -replace '^v', ''
if ($v -notmatch '^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$') { Fail "Tag '$($env:GITHUB_REF_NAME)' is not v<semver>" }
if (-not $env:PACK_ID) { Fail 'pack-id is required when release: true' }
$app = if ($env:APP_INPUT) { $env:APP_INPUT } else { $env:GITHUB_REPOSITORY.Split('/')[1] }
$app = $app.ToLowerInvariant()
if ($app -cnotmatch '^[a-z0-9][a-z0-9._-]*$' -or $app.Contains('..')) { Fail "app '$app' must be [a-z0-9._-]" }
if ($env:R2_ACCOUNT_ID -notmatch '^[0-9a-f]{32}$') { Fail 'Actions variable R2_ACCOUNT_ID is missing or not a 32-hex Cloudflare account ID' }
"version=$v" >> $env:GITHUB_OUTPUT
"app=$app" >> $env:GITHUB_OUTPUT
"VPK_PREFIX=$app/" >> $env:GITHUB_ENV # trailing slash: objects become <app>/releases.win.json
Write-Host "Release $($env:PACK_ID) $v -> https://releases.poli0981.dev/$app/"
- name: Publish (self-contained, ${{ inputs.rid }})
run: >
dotnet publish ${{ inputs.project }}
--configuration ${{ inputs.configuration }}
--runtime ${{ inputs.rid }}
--self-contained true
--output publish
"/p:Version=${{ steps.ver.outputs.version }}"
- name: Install Velopack CLI ${{ inputs.vpk-version }} (per-job tool path)
shell: pwsh
env:
VPK_VERSION: ${{ inputs.vpk-version }}
run: |
$tmp = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { [IO.Path]::GetTempPath() }
$dir = Join-Path $tmp 'vpk'
dotnet tool update vpk --version $env:VPK_VERSION --tool-path $dir # installs when missing
if ($LASTEXITCODE) { exit $LASTEXITCODE }
$dir >> $env:GITHUB_PATH
- name: Download previous release from R2 (enables delta packages)
continue-on-error: true # first release: nothing to download yet
env:
VPK_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
VPK_SECRET: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
run: vpk download s3 --channel win -o releases
- name: Velopack pack
shell: pwsh
env:
PACK_ID: ${{ inputs.pack-id }}
MAIN_EXE: ${{ inputs.main-exe }}
PACK_VERSION: ${{ steps.ver.outputs.version }}
run: |
$exe = $env:MAIN_EXE
if (-not $exe) { $exe = "$($env:PACK_ID).exe" }
vpk pack `
--packId $env:PACK_ID `
--packVersion $env:PACK_VERSION `
--packDir publish `
--mainExe $exe `
--outputDir releases
if ($LASTEXITCODE) { exit $LASTEXITCODE }
- name: Upload to R2 (packages first, feeds last — handled by vpk)
env:
VPK_KEY_ID: ${{ secrets.R2_RELEASES_ACCESS_KEY_ID }}
VPK_SECRET: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
run: vpk upload s3 --channel win -o releases --keepMaxReleases 10
- name: Smoke test + release notes (links only)
shell: pwsh
env:
APP: ${{ steps.ver.outputs.app }}
PACK_ID: ${{ inputs.pack-id }}
PACK_VERSION: ${{ steps.ver.outputs.version }}
run: |
$base = "https://releases.poli0981.dev/$($env:APP)"
# Stable-named files written by vpk pack (cache-bypassed at the edge, runbook §1)
$setup = Get-ChildItem -LiteralPath releases -Filter '*-Setup.exe' -File | Select-Object -First 1
$portable = Get-ChildItem -LiteralPath releases -Filter '*-Portable.zip' -File | Select-Object -First 1
$check = @('releases.win.json') + @($setup, $portable | Where-Object { $_ } | ForEach-Object { $_.Name })
foreach ($name in $check) {
$url = "$base/$([Uri]::EscapeDataString($name))"
$code = curl.exe -sS -o NUL -I -w '%{http_code}' --retry 3 --retry-all-errors $url
Write-Host "HEAD $url -> $code"
if ($code -ne '200') { Write-Host "::error::Not reachable after upload: $url"; exit 1 }
}
$lines = @("$($env:PACK_ID) $($env:PACK_VERSION)", '', '**Download (Windows x64)**', '')
if ($setup) { $lines += "- Installer: [$($setup.Name)]($base/$([Uri]::EscapeDataString($setup.Name)))" }
if ($portable) { $lines += "- Portable: [$($portable.Name)]($base/$([Uri]::EscapeDataString($portable.Name)))" }
$lines += '', "Installed copies update automatically from $base."
Set-Content -LiteralPath release-notes.md -Value $lines -Encoding utf8
Get-Content -LiteralPath release-notes.md
- name: Create Gitea release (notes + links, no binaries)
uses: https://gitea.com/actions/gitea-release-action@5a83c90484ef4355121df5eb60558c8ce66e81ac # v1.3.7
with:
tag_name: ${{ github.ref_name }}
name: ${{ inputs.pack-id }} ${{ steps.ver.outputs.version }}
body_path: release-notes.md
@@ -1,7 +1,11 @@
# Reusable CI for Go projects
#
# Verified 2026-07-06: Go 1.26.4 = latest stable ('stable' alias resolves to it),
# setup-go v6 (6.5.0), checkout v7, ubuntu-latest = Ubuntu 24.04
# Lives in poli0981/.github (Gitea) → called via:
# uses: poli0981/.github/.gitea/workflows/reusable-go.yml@<full-sha> # ops vYYYY.MM.N
#
# Gitea port 2026-11-23: ubuntu-latest = Docker image docker.gitea.com/runner-images.
# 'stable' resolves to the latest Go release via setup-go. Actions pinned to commit
# SHAs (Renovate keeps them current).
name: Reusable / Go
@@ -21,16 +25,16 @@ on:
jobs:
build-test:
runs-on: ubuntu-latest # = Ubuntu 24.04 LTS
runs-on: ubuntu-latest # Gitea: Docker, docker.gitea.com/runner-images
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Go (${{ inputs.go-version }})
uses: actions/setup-go@v6
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version: ${{ inputs.go-version }}
check-latest: true
@@ -1,10 +1,16 @@
# Reusable CI for JVM projects — covers BOTH Java and Kotlin repos
# (Kotlin is a JVM language: same JDK setup + Gradle build, so one reusable serves both.)
#
# Verified 2026-07-06: Java 25 = current LTS (Temurin), setup-java v5 (v5.4.0),
# checkout v7, upload-artifact v7, ubuntu-latest = Ubuntu 24.04
# NOTE for Kotlin/Gradle repos: Gradle wrapper must be 9.x+ to run on JDK 25;
# Lives in poli0981/.github (Gitea) → called via:
# uses: poli0981/.github/.gitea/workflows/reusable-jvm.yml@<full-sha> # ops vYYYY.MM.N
#
# Java 25 = current LTS (Temurin). Gradle wrapper must be 9.x+ to run on JDK 25;
# older projects can pass java-version: '21' (previous LTS) instead.
#
# Gitea port 2026-11-23: ubuntu-latest = Docker image docker.gitea.com/runner-images.
# The Maven path needs `mvn` in that image (GitHub images shipped it) — VERIFY on pilot.
# Test reports use christopherhx/gitea-upload-artifact (upstream upload-artifact v4+
# refuses non-GitHub servers). Actions pinned to commit SHAs (Renovate).
name: Reusable / JVM (Java + Kotlin)
@@ -27,16 +33,16 @@ on:
jobs:
build-test:
runs-on: ubuntu-latest # = Ubuntu 24.04 LTS
runs-on: ubuntu-latest # Gitea: Docker, docker.gitea.com/runner-images
timeout-minutes: 30
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup JDK ${{ inputs.java-version }} (${{ inputs.distribution }})
uses: actions/setup-java@v5
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
with:
java-version: ${{ inputs.java-version }}
distribution: ${{ inputs.distribution }}
@@ -65,7 +71,7 @@ jobs:
- name: Upload test reports on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v7
uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
name: test-reports
path: |
@@ -1,6 +1,17 @@
# ─────────────────────────────────────────────────────────────────────────────
# DISABLED ON GITEA — no macOS runner (Gitea migration 2026-11-23, runbook §4.1 / §5.6).
# The only runner is the maintainer's Windows PC (windows-latest = host mode,
# ubuntu-* = Docker). The file is kept for the future with its inputs unchanged,
# so existing callers still resolve; the job is guarded with `if: false` and
# always shows as skipped. Re-enable only once a macOS runner is registered.
# ─────────────────────────────────────────────────────────────────────────────
#
# Reusable CI for macOS utilities (Swift / SwiftUI)
#
# Verified 2026-07-06:
# Lives in poli0981/.github (Gitea) → called via:
# uses: poli0981/.github/.gitea/workflows/reusable-macos-swift.yml@<full-sha> # ops vYYYY.MM.N
#
# GitHub-hosted reference (2026-07-06):
# macos-26 runner → Xcode 26.5 default (latest Swift toolchain)
# macos-latest → macOS 15, Xcode 16.4 default
# Toolchain comes from the selected Xcode, so the runner/xcode-version inputs control Swift version.
@@ -32,13 +43,14 @@ on:
jobs:
build-test:
if: false # no macOS runner (Gitea)
runs-on: ${{ inputs.runner }}
timeout-minutes: 30
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Select Xcode ${{ inputs.xcode-version }}
if: ${{ inputs.xcode-version != '' }}
@@ -1,9 +1,13 @@
# Reusable CI for PHP projects
# NOTE: CodeQL does NOT support PHP — this repo type gets CI + Dependabot only.
# (Consider PHPStan/Psalm in the repo's own composer scripts for static analysis.)
# Static analysis: consider PHPStan/Psalm in the repo's own composer scripts.
# Dependency updates come from Renovate, secrets/deps scanning from security.yml.
#
# Verified 2026-07-06: PHP 8.5.8 = latest stable, shivammathur/setup-php 2.37.2
# (community-standard action, pinned major v2), checkout v7, ubuntu-latest = Ubuntu 24.04
# Lives in poli0981/.github (Gitea) → called via:
# uses: poli0981/.github/.gitea/workflows/reusable-php.yml@<full-sha> # ops vYYYY.MM.N
#
# Gitea port 2026-11-23: ubuntu-latest = Docker image docker.gitea.com/runner-images.
# shivammathur/setup-php installs PHP via apt/ppa inside that image (VERIFY on pilot).
# Actions pinned to commit SHAs (Renovate keeps them current).
name: Reusable / PHP
@@ -22,16 +26,16 @@ on:
jobs:
build-test:
runs-on: ubuntu-latest # = Ubuntu 24.04 LTS
runs-on: ubuntu-latest # Gitea: Docker, docker.gitea.com/runner-images
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup PHP ${{ inputs.php-version }}
uses: shivammathur/setup-php@v2
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
with:
php-version: ${{ inputs.php-version }}
extensions: ${{ inputs.extensions }}
@@ -1,7 +1,11 @@
# Reusable CI for Python projects (automation scripts, bots, scrapers)
#
# Verified 2026-07-06: Python 3.14.6 = latest stable (3.15 not yet released),
# ubuntu-latest = Ubuntu 24.04, checkout v7, setup-python v6, upload-artifact v7
# Lives in poli0981/.github (Gitea) → called via:
# uses: poli0981/.github/.gitea/workflows/reusable-python.yml@<full-sha> # ops vYYYY.MM.N
#
# Gitea port 2026-11-23: ubuntu-latest = Docker image docker.gitea.com/runner-images.
# setup-python downloads CPython builds from actions/python-versions; the pip cache
# goes to the Gitea runner's cache server. Actions pinned to commit SHAs (Renovate).
name: Reusable / Python
@@ -35,16 +39,16 @@ on:
jobs:
lint:
if: ${{ inputs.lint != 'none' }}
runs-on: ubuntu-latest # = Ubuntu 24.04 LTS
runs-on: ubuntu-latest # Gitea: Docker, docker.gitea.com/runner-images
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Python ${{ inputs.lint-python-version }}
uses: actions/setup-python@v6
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: ${{ inputs.lint-python-version }}
@@ -78,10 +82,10 @@ jobs:
python-version: ${{ fromJSON(inputs.python-versions) }}
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: ${{ matrix.python-version }}
cache: pip
+93
View File
@@ -0,0 +1,93 @@
# Reusable CI for R projects
# NOTE: no SAST rules / dependency ecosystem for R in security.yml — this repo type
# gets CI plus the gitleaks job of security.yml.
#
# Lives in poli0981/.github (Gitea) → called via:
# uses: poli0981/.github/.gitea/workflows/reusable-r.yml@<full-sha> # ops vYYYY.MM.N
#
# Gitea port 2026-11-23: ubuntu-latest = Docker image docker.gitea.com/runner-images.
# r-lib/actions/check-r-package uploads results with upstream actions/upload-artifact,
# which refuses non-GitHub servers, so its built-in uploads are switched off and the
# same files are uploaded with christopherhx/gitea-upload-artifact instead.
# Actions pinned to commit SHAs (Renovate keeps them current).
name: Reusable / R
on:
workflow_call:
inputs:
r-version:
description: "'release' = always latest R release; or pin e.g. '4.6.1'"
type: string
default: 'release'
type:
description: "'package' = R CMD check via r-lib | 'scripts' = run a test script"
type: string
default: 'package'
test-script:
description: 'Entry script for scripts mode (run if it exists)'
type: string
default: 'tests/run_tests.R'
jobs:
check:
runs-on: ubuntu-latest # Gitea: Docker, docker.gitea.com/runner-images
timeout-minutes: 30
permissions:
contents: read
env:
R_KEEP_PKG_SOURCE: yes
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup R (${{ inputs.r-version }})
uses: r-lib/actions/setup-r@f9a764fea8d5c63df6ef9a5c7795bf7deb5d7e05 # v2.14.0
with:
r-version: ${{ inputs.r-version }}
use-public-rspm: true # binary packages from Posit PPM = much faster installs
# --- R package path: dependency install + R CMD check ---
- name: Install package dependencies
if: ${{ inputs.type == 'package' }}
uses: r-lib/actions/setup-r-dependencies@f9a764fea8d5c63df6ef9a5c7795bf7deb5d7e05 # v2.14.0
with:
extra-packages: any::rcmdcheck
needs: check
- name: R CMD check
if: ${{ inputs.type == 'package' }}
uses: r-lib/actions/check-r-package@f9a764fea8d5c63df6ef9a5c7795bf7deb5d7e05 # v2.14.0
with:
upload-snapshots: false # built-in upload uses upstream upload-artifact (not on Gitea)
upload-results: never
- name: Upload testthat snapshots
if: ${{ inputs.type == 'package' && always() }}
uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
name: testthat-snapshots
path: check/**/tests*/testthat/_snaps
if-no-files-found: ignore
retention-days: 14
- name: Upload check results on failure
if: ${{ inputs.type == 'package' && failure() }}
uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
name: r-check-results
path: check
if-no-files-found: ignore
retention-days: 14
# --- Scripts path: run test entry script if present ---
- name: Run test script
if: ${{ inputs.type == 'scripts' }}
run: |
if [ -f "${{ inputs.test-script }}" ]; then
Rscript "${{ inputs.test-script }}"
else
echo "No ${{ inputs.test-script }} — running syntax parse check on all .R files"
find . -name '*.R' -not -path './.git/*' -print0 \
| xargs -0 -r -n1 -I{} Rscript -e 'invisible(parse("{}"))'
fi
@@ -1,7 +1,11 @@
# Reusable CI for Ruby projects
#
# Verified 2026-07-06: Ruby 3.4.10 = latest stable, ruby/setup-ruby v1 (v1.316.0),
# checkout v7, ubuntu-latest = Ubuntu 24.04
# Lives in poli0981/.github (Gitea) → called via:
# uses: poli0981/.github/.gitea/workflows/reusable-ruby.yml@<full-sha> # ops vYYYY.MM.N
#
# Gitea port 2026-11-23: ubuntu-latest = Docker image docker.gitea.com/runner-images.
# ruby/setup-ruby picks prebuilt Rubies by the image's ImageOS (VERIFY on pilot).
# Actions pinned to commit SHAs (Renovate keeps them current).
name: Reusable / Ruby
@@ -22,16 +26,16 @@ on:
jobs:
build-test:
runs-on: ubuntu-latest # = Ubuntu 24.04 LTS
runs-on: ubuntu-latest # Gitea: Docker, docker.gitea.com/runner-images
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Ruby ${{ inputs.ruby-version }}
uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@be3c7df29b3349ec6bcfc6b4792f1cf9f5237d18 # v1.343.0
with:
ruby-version: ${{ inputs.ruby-version }}
bundler-cache: true # bundle install + cache automatically
+176
View File
@@ -0,0 +1,176 @@
# Reusable CI + Cloudflare Workers deploy for web apps (React 19 / Vite / TypeScript / Vitest)
# Lint / typecheck / test steps run only when the matching npm script exists — safe across repos.
#
# Lives in poli0981/.github (Gitea) → called via:
# uses: poli0981/.github/.gitea/workflows/reusable-web-react.yml@<full-sha> # ops vYYYY.MM.N
#
# Deploy (push to main, runbook §5.3):
# jobs:
# deploy:
# permissions:
# contents: read
# uses: poli0981/.github/.gitea/workflows/reusable-web-react.yml@<full-sha> # ops vYYYY.MM.N
# with:
# deploy-workers: true
# secrets:
# CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
# CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
#
# Gitea port 2026-11-23: GitHub Pages is not available, so the former `deploy-pages` mode
# (configure-pages / upload-pages-artifact / deploy-pages + id-token) is REMOVED and replaced by
# `deploy-workers`: `wrangler deploy` with the repo's own wrangler config (wrangler.jsonc /
# wrangler.toml with static assets → the build output). The repo's wrangler devDependency is used
# when present, otherwise the pinned `wrangler-version`. Disconnect Cloudflare's GitHub
# integration for the project (dashboard). Actions pinned to commit SHAs (Renovate).
name: Reusable / Web React
on:
workflow_call:
inputs:
node-version:
type: string
default: '24' # Node 24 = active LTS
package-manager:
description: "'npm' | 'pnpm'"
type: string
default: 'npm'
build-command:
type: string
default: 'npm run build'
test-command:
description: 'Runs only if a "test" script exists in package.json'
type: string
default: 'npx vitest run'
dist-dir:
type: string
default: 'dist'
deploy-workers:
description: 'true = build + `wrangler deploy` to Cloudflare Workers (call from a main-branch push workflow; needs a wrangler config in the repo)'
type: boolean
default: false
wrangler-version:
description: 'wrangler used when the repo has no local wrangler devDependency'
type: string
default: '4.159.0'
secrets:
CLOUDFLARE_API_TOKEN:
required: false # only for deploy-workers: true
CLOUDFLARE_ACCOUNT_ID:
required: false
jobs:
build:
if: ${{ !inputs.deploy-workers }}
runs-on: ubuntu-latest # Gitea: Docker, docker.gitea.com/runner-images
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup pnpm
if: ${{ inputs.package-manager == 'pnpm' }}
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- name: Setup Node.js ${{ inputs.node-version }}
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: ${{ inputs.node-version }}
cache: ${{ inputs.package-manager }}
- name: Install dependencies
run: |
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm install --frozen-lockfile
else
npm ci
fi
- name: Lint (if script exists)
run: |
if jq -e '.scripts.lint' package.json > /dev/null; then
${{ inputs.package-manager }} run lint
else
echo "No lint script — skipping"
fi
- name: Typecheck (if script exists)
run: |
if jq -e '.scripts.typecheck' package.json > /dev/null; then
${{ inputs.package-manager }} run typecheck
else
echo "No typecheck script — skipping"
fi
- name: Test (if script exists)
run: |
if jq -e '.scripts.test' package.json > /dev/null; then
${{ inputs.test-command }}
else
echo "No test script — skipping"
fi
- name: Build
run: ${{ inputs.build-command }}
- name: Upload build artifact
uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
name: dist
path: ${{ inputs.dist-dir }}
retention-days: 14
deploy:
# Deploy credentials: pushes or manual runs only, never pull_request / schedule
if: ${{ inputs.deploy-workers && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup pnpm
if: ${{ inputs.package-manager == 'pnpm' }}
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- name: Setup Node.js ${{ inputs.node-version }}
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: ${{ inputs.node-version }}
cache: ${{ inputs.package-manager }}
- name: Install + build
run: |
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm install --frozen-lockfile
else
npm ci
fi
${{ inputs.build-command }}
- name: Deploy to Cloudflare Workers (wrangler deploy)
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
WRANGLER_VERSION: ${{ inputs.wrangler-version }}
WRANGLER_SEND_METRICS: 'false'
run: |
set -euo pipefail
if [ -z "$CLOUDFLARE_API_TOKEN" ] || [ -z "$CLOUDFLARE_ACCOUNT_ID" ]; then
echo "::error::CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID secrets were not passed"; exit 1
fi
found=""
for f in wrangler.jsonc wrangler.json wrangler.toml; do [ -f "$f" ] && found="$f" && break; done
if [ -z "$found" ]; then
echo "::error::No wrangler.jsonc / wrangler.json / wrangler.toml in the repo root"; exit 1
fi
echo "Using $found"
if [ -x node_modules/.bin/wrangler ]; then
node_modules/.bin/wrangler deploy
else
npx --yes "wrangler@${WRANGLER_VERSION}" deploy
fi
+350
View File
@@ -0,0 +1,350 @@
# Reusable security checks for every repo (runbook §4.3)
#
# secrets → gitleaks: full git history, redacted output, FAILS on findings
# (.gitleaks.toml / .gitleaksignore in the caller repo are honoured)
# sast → Opengrep with pinned community rules (opengrep/opengrep-rules @ commit),
# --taint-intrafile; SARIF uploaded as an artifact (Gitea has no code-scanning UI).
# Report-only by default; `sast-fail-on-findings: true` makes findings fail the job.
# deps → osv-scanner over the lockfiles it finds (packages.lock.json, pnpm-lock.yaml,
# Cargo.lock, uv.lock, …); FAILS on known vulnerabilities
# rust → cargo-deny (the repo's deny.toml), only when rust: true
# dotnet → dotnet restore with NuGetAudit (transitive); FAILS on NU1903 / NU1904
# (high / critical) only, only when dotnet: true
#
# Lives in poli0981/.github (Gitea) → called via:
# on:
# push:
# branches: [main]
# pull_request:
# schedule:
# - cron: '43 14 * * 6' # weekly, inside 13:00–16:00 UTC; pick a FREE slot (runbook §8)
# workflow_dispatch:
# permissions:
# contents: read
# jobs:
# security:
# uses: poli0981/.github/.gitea/workflows/security.yml@<full-sha> # ops vYYYY.MM.N
# with:
# dotnet: true
# dotnet-runs-on: windows-latest # only for net*-windows solutions
#
# Tools are downloaded at pinned versions and SHA-256 verified. Renovate does not update
# them (they are not actions): bump version + checksum together, by hand.
# VERIFY on pilot: exact CLI flags (`<tool> --help`) and exit codes on these versions.
# The dotnet job with dotnet-runs-on: windows-latest runs in HOST MODE on the maintainer PC;
# outside contributors cannot open PRs on Gitea (registration disabled), keep it that way.
name: Reusable / Security
on:
workflow_call:
inputs:
rust:
description: 'cargo-deny + Rust SAST rules'
type: boolean
default: false
node:
description: 'JavaScript / TypeScript SAST rules'
type: boolean
default: false
dotnet:
description: 'NuGetAudit restore + C# SAST rules'
type: boolean
default: false
python:
description: 'Python SAST rules'
type: boolean
default: false
dotnet-runs-on:
description: "'ubuntu-latest' | 'windows-latest' (needed when the solution targets net*-windows)"
type: string
default: 'ubuntu-latest'
dotnet-solution:
description: 'Solution / project to restore (empty = the single one in the repo root)'
type: string
default: ''
dotnet-version:
description: '.NET SDK used for the restore'
type: string
default: '10.0.x'
cargo-manifest-path:
description: 'Cargo.toml to check (empty = ./Cargo.toml, else ./src-tauri/Cargo.toml)'
type: string
default: ''
sast-fail-on-findings:
description: 'true = Opengrep findings fail the sast job (default: report only)'
type: boolean
default: false
permissions:
contents: read
jobs:
secrets:
name: Secrets (gitleaks)
runs-on: ubuntu-latest # Gitea: Docker, docker.gitea.com/runner-images
timeout-minutes: 15
permissions:
contents: read
env:
GITLEAKS_VERSION: 8.30.1
GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb # gitleaks_8.30.1_linux_x64.tar.gz
steps:
- name: Checkout (full history)
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Install gitleaks ${{ env.GITLEAKS_VERSION }}
run: |
set -euo pipefail
tmp="${RUNNER_TEMP:-/tmp}"
tgz="$tmp/gitleaks.tar.gz"
curl -fsSL --retry 3 -o "$tgz" \
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
echo "${GITLEAKS_SHA256} $tgz" | sha256sum -c -
mkdir -p "$tmp/gitleaks"
tar -xzf "$tgz" -C "$tmp/gitleaks" gitleaks
echo "$tmp/gitleaks" >> "$GITHUB_PATH"
- name: Scan full git history
run: |
gitleaks version
gitleaks git --redact --no-banner --verbose --exit-code 1 \
--report-format sarif --report-path gitleaks.sarif .
- name: Upload report (redacted)
if: ${{ always() }}
uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
name: gitleaks-sarif
path: gitleaks.sarif
if-no-files-found: ignore
retention-days: 14
sast:
name: SAST (Opengrep)
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
env:
OPENGREP_VERSION: v1.33.1
OPENGREP_SHA256: 46e8133cc490f9f50518061590ce2f6be5a08afaeda034471c0ceda4b3899808 # opengrep_manylinux_x86
OPENGREP_RULES_REPO: https://github.com/opengrep/opengrep-rules.git
OPENGREP_RULES_SHA: f1d2b562b414783763fd02a6ed2736eaed622efa # pinned rule source
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Opengrep ${{ env.OPENGREP_VERSION }}
run: |
set -euo pipefail
tmp="${RUNNER_TEMP:-/tmp}"
mkdir -p "$tmp/opengrep/bin"
bin="$tmp/opengrep/bin/opengrep"
curl -fsSL --retry 3 -o "$bin" \
"https://github.com/opengrep/opengrep/releases/download/${OPENGREP_VERSION}/opengrep_manylinux_x86"
echo "${OPENGREP_SHA256} $bin" | sha256sum -c -
chmod +x "$bin"
echo "$tmp/opengrep/bin" >> "$GITHUB_PATH"
- name: Fetch rules at pinned commit
run: |
set -euo pipefail
rules="${RUNNER_TEMP:-/tmp}/opengrep-rules" # outside the workspace: never scanned
git init -q "$rules"
git -C "$rules" fetch -q --depth 1 "$OPENGREP_RULES_REPO" "$OPENGREP_RULES_SHA"
git -C "$rules" checkout -q FETCH_HEAD
test "$(git -C "$rules" rev-parse HEAD)" = "$OPENGREP_RULES_SHA"
echo "OPENGREP_RULES_DIR=$rules" >> "$GITHUB_ENV"
- name: Scan
env:
WITH_PYTHON: ${{ inputs.python }}
WITH_NODE: ${{ inputs.node }}
WITH_DOTNET: ${{ inputs.dotnet }}
WITH_RUST: ${{ inputs.rust }}
FAIL_ON_FINDINGS: ${{ inputs.sast-fail-on-findings }}
run: |
set -euo pipefail
# Always: CI workflow injection / pinning, Dockerfiles, shell scripts
sets=(yaml/github-actions dockerfile bash)
[ "$WITH_PYTHON" = "true" ] && sets+=(python)
[ "$WITH_NODE" = "true" ] && sets+=(javascript typescript)
[ "$WITH_DOTNET" = "true" ] && sets+=(csharp)
[ "$WITH_RUST" = "true" ] && sets+=(rust)
args=()
for s in "${sets[@]}"; do
[ -d "$OPENGREP_RULES_DIR/$s" ] || { echo "::error::rule set '$s' missing at $OPENGREP_RULES_SHA"; exit 1; }
args+=(--config "$OPENGREP_RULES_DIR/$s")
done
[ "$FAIL_ON_FINDINGS" = "true" ] && args+=(--error)
echo "Rule sets: ${sets[*]}"
opengrep --version
opengrep scan --taint-intrafile --sarif-output=opengrep.sarif "${args[@]}" .
- name: Upload SARIF
if: ${{ always() }}
uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
name: opengrep-sarif
path: opengrep.sarif
if-no-files-found: ignore
retention-days: 14
deps:
name: Dependencies (osv-scanner)
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
env:
OSV_SCANNER_VERSION: v2.7.1
OSV_SCANNER_SHA256: fb7dab19a8bd9bbe5c3189f09d4b7ee1820c9553a23bac202648a56efd2f6ee8 # osv-scanner_linux_amd64
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install osv-scanner ${{ env.OSV_SCANNER_VERSION }}
run: |
set -euo pipefail
tmp="${RUNNER_TEMP:-/tmp}"
mkdir -p "$tmp/osv-scanner"
bin="$tmp/osv-scanner/osv-scanner"
curl -fsSL --retry 3 -o "$bin" \
"https://github.com/google/osv-scanner/releases/download/${OSV_SCANNER_VERSION}/osv-scanner_linux_amd64"
echo "${OSV_SCANNER_SHA256} $bin" | sha256sum -c -
chmod +x "$bin"
echo "$tmp/osv-scanner" >> "$GITHUB_PATH"
- name: Scan lockfiles
run: |
set -uo pipefail
osv-scanner --version
osv-scanner scan source --recursive --allow-no-lockfiles .
rc=$?
osv-scanner scan source --recursive --allow-no-lockfiles \
--format sarif --output-file osv-scanner.sarif . >/dev/null 2>&1 || true
case "$rc" in
0) echo "No known vulnerabilities." ;;
1) echo "::error::Known vulnerabilities in dependencies (see table above / osv-scanner-sarif artifact)"; exit 1 ;;
128) echo "No lockfiles / packages found — nothing to scan." ;;
*) echo "::error::osv-scanner failed (exit $rc)"; exit "$rc" ;;
esac
- name: Upload SARIF
if: ${{ always() }}
uses: christopherhx/gitea-upload-artifact@81f940d004763f986ba3582c007fd842dd5cb0d7 # v4
with:
name: osv-scanner-sarif
path: osv-scanner.sarif
if-no-files-found: ignore
retention-days: 14
rust:
name: Rust (cargo-deny)
if: ${{ inputs.rust }}
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
env:
CARGO_DENY_VERSION: 0.20.2
CARGO_DENY_SHA256: 9f12ed4c49936e09b48bf862b595cde2fe64fcbd9d74dfacac6131ca824c8d5f # cargo-deny-0.20.2-x86_64-unknown-linux-musl.tar.gz
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Rust (stable)
uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master
with:
toolchain: stable
- name: Install cargo-deny ${{ env.CARGO_DENY_VERSION }}
run: |
set -euo pipefail
tmp="${RUNNER_TEMP:-/tmp}"
pkg="cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl"
curl -fsSL --retry 3 -o "$tmp/$pkg.tar.gz" \
"https://github.com/EmbarkStudios/cargo-deny/releases/download/${CARGO_DENY_VERSION}/$pkg.tar.gz"
echo "${CARGO_DENY_SHA256} $tmp/$pkg.tar.gz" | sha256sum -c -
mkdir -p "$tmp/cargo-deny"
tar -xzf "$tmp/$pkg.tar.gz" -C "$tmp/cargo-deny" --strip-components=1
echo "$tmp/cargo-deny" >> "$GITHUB_PATH"
- name: cargo deny check
env:
MANIFEST_INPUT: ${{ inputs.cargo-manifest-path }}
run: |
set -euo pipefail
manifest="$MANIFEST_INPUT"
if [ -z "$manifest" ]; then
if [ -f Cargo.toml ]; then manifest=Cargo.toml
elif [ -f src-tauri/Cargo.toml ]; then manifest=src-tauri/Cargo.toml
else echo "::error::No Cargo.toml found (set cargo-manifest-path)"; exit 1
fi
fi
cargo deny --version
# advisories + licenses (GPL-3.0 compatible) + sources (crates.io only), per deny.toml
cargo deny --manifest-path "$manifest" --all-features check
dotnet:
name: .NET (NuGetAudit)
if: ${{ inputs.dotnet }}
runs-on: ${{ inputs.dotnet-runs-on }}
timeout-minutes: 20
permissions:
contents: read
env:
DOTNET_CLI_TELEMETRY_OPTOUT: '1'
DOTNET_NOLOGO: '1'
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Keep .NET SDK installs in the runner tool cache (Windows host mode)
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
$base = if ($env:RUNNER_TOOL_CACHE) { $env:RUNNER_TOOL_CACHE } else { Join-Path $env:LOCALAPPDATA 'gitea-runner\toolcache' }
"DOTNET_INSTALL_DIR=$(Join-Path $base 'dotnet')" >> $env:GITHUB_ENV
- name: Setup .NET ${{ inputs.dotnet-version }}
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0
with:
dotnet-version: ${{ inputs.dotnet-version }}
- name: Restore with NuGetAudit (Linux)
if: ${{ runner.os != 'Windows' }}
shell: bash
env:
SOLUTION: ${{ inputs.dotnet-solution }}
run: |
set -uo pipefail
# shellcheck disable=SC2086
dotnet restore $SOLUTION --force -p:NuGetAudit=true -p:NuGetAuditMode=all 2>&1 | tee restore.log
rc=${PIPESTATUS[0]}
if grep -E 'NU190[34]' restore.log; then
echo "::error::High/critical vulnerable NuGet packages (NU1903/NU1904)"; exit 1
fi
exit "$rc"
- name: Restore with NuGetAudit (Windows)
if: ${{ runner.os == 'Windows' }}
shell: pwsh
env:
SOLUTION: ${{ inputs.dotnet-solution }}
run: |
$restoreArgs = @('restore')
if ($env:SOLUTION) { $restoreArgs += $env:SOLUTION }
$restoreArgs += @('--force', '-p:NuGetAudit=true', '-p:NuGetAuditMode=all')
& dotnet @restoreArgs 2>&1 | Tee-Object -FilePath restore.log
$rc = $LASTEXITCODE
$hits = Select-String -Path restore.log -Pattern 'NU190[34]'
if ($hits) {
$hits | ForEach-Object { Write-Host $_.Line }
Write-Host '::error::High/critical vulnerable NuGet packages (NU1903/NU1904)'
exit 1
}
exit $rc
+50
View File
@@ -0,0 +1,50 @@
name: Weekly Digest
# Lives in poli0981/.github. Every Sunday 14:07 UTC = 21:07 Vietnam (inside the
# 13:00–16:00 UTC window, runbook §1 / §3.2.9). Aggregates the last 7 days of
# activity (merged PRs, closed issues, published releases) across the repos owned
# by poli0981 on Gitea and posts a summary to #announcements.
# If the PC is off, the run waits as "waiting" and starts when the runner comes
# online; after 24 h unpicked it is cancelled (ABANDONED_JOB_TIMEOUT).
#
# Required repo secrets (set on poli0981/.github):
# DISCORD_DIGEST_WEBHOOK — webhook for #announcements
# OPS_GITEA_TOKEN — Gitea PAT (Settings → Applications), scopes:
# read:repository + read:issue. The job token
# (GITEA_TOKEN) only sees this repo, so it cannot
# aggregate the others.
#
# Run on demand: Actions → Weekly Digest → Run workflow
on:
schedule:
- cron: '7 14 * * 0' # Sunday 14:07 UTC = 21:07 Vietnam
workflow_dispatch:
permissions:
contents: read
concurrency:
group: weekly-digest
cancel-in-progress: false
jobs:
digest:
runs-on: ubuntu-latest # Gitea: Docker, docker.gitea.com/runner-images
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
sparse-checkout: |
.github/scripts
sparse-checkout-cone-mode: false
- name: Post weekly digest
env:
DISCORD_DIGEST_WEBHOOK: ${{ secrets.DISCORD_DIGEST_WEBHOOK }}
OPS_GITEA_TOKEN: ${{ secrets.OPS_GITEA_TOKEN }}
GITEA_API_URL: ${{ github.api_url }}
GH_OWNER: ${{ github.repository_owner }}
run: python3 .github/scripts/discord_notify.py weekly-digest
+90 -174
View File
@@ -1,13 +1,12 @@
"""
Discord webhook notification helper — phase 2.
Extends phase 1 with four new commands:
Extends phase 1 with three new commands:
python discord_notify.py release # phase 1: release announcement
python discord_notify.py failure # phase 1: generic CI failure
python discord_notify.py deploy # phase 2: deploy success/fail
python discord_notify.py release-build # phase 2: release pipeline build status
python discord_notify.py dependabot-summary # phase 2: org-wide dependabot digest
python discord_notify.py weekly-digest # phase 2: org-wide weekly activity
Stdlib-only. Drop into .github/scripts/ in any repo.
@@ -21,7 +20,7 @@ import sys
from collections import defaultdict
from datetime import datetime, timedelta, timezone
from urllib.error import HTTPError, URLError
from urllib.parse import urlencode
from urllib.parse import quote, urlencode
from urllib.request import Request, urlopen
# ---------- Embed colors ----------
@@ -33,7 +32,6 @@ COLOR_DEPLOY_OK = 0x3BA55D # darker green (distinct from release)
COLOR_DEPLOY_FAIL = 0xE74C3C # darker red
COLOR_BUILD_OK = 0x5865F2 # blurple — neutral build success
COLOR_BUILD_FAIL = 0xED4245
COLOR_DEPENDABOT = 0xFAA61A # orange
COLOR_DIGEST = 0x9B59B6 # purple
# ---------- Truncation limits ----------
@@ -63,7 +61,7 @@ def _post_webhook(url: str, payload: dict) -> bool:
data=body,
headers={
"Content-Type": "application/json",
"User-Agent": "poli0981-cicd/2.0 (+https://github.com/poli0981)",
"User-Agent": "poli0981-cicd/2.0 (+https://git.poli0981.dev/poli0981)",
},
)
@@ -80,20 +78,35 @@ def _post_webhook(url: str, payload: dict) -> bool:
return False
def _gh_api(path: str, token: str, method: str = "GET", params: dict | None = None) -> dict | list:
"""Call GitHub REST API. Returns parsed JSON."""
base = "https://api.github.com"
# Gitea REST API (/api/v1). Listing endpoints return at most [api] MAX_RESPONSE_ITEMS
# items per page (50 by default), so listings are paged until the first empty page.
GITEA_PAGE_LIMIT = 50
GITEA_MAX_PAGES = 20 # safety cap: 1000 items per listing
def _gitea_api_base() -> str:
"""API root, e.g. https://git.poli0981.dev/api/v1 (GITEA_API_URL, else server URL)."""
base = _env("GITEA_API_URL")
if not base:
server = _env("GITHUB_SERVER_URL")
if not server:
print("[ERROR] Neither GITEA_API_URL nor GITHUB_SERVER_URL is set.")
sys.exit(1)
base = server.rstrip("/") + "/api/v1"
return base.rstrip("/")
def _gitea_api(base: str, path: str, token: str, params: dict | None = None) -> dict | list:
"""GET a Gitea REST API path (relative to /api/v1). Returns parsed JSON."""
url = f"{base}{path}"
if params:
url += "?" + urlencode(params)
req = Request(
url,
method=method,
headers={
"Accept": "application/vnd.github+json",
"Authorization": f"Bearer {token}",
"X-GitHub-Api-Version": "2022-11-28",
"Accept": "application/json",
"Authorization": f"token {token}",
"User-Agent": "poli0981-cicd/2.0",
},
)
@@ -102,19 +115,33 @@ def _gh_api(path: str, token: str, method: str = "GET", params: dict | None = No
with urlopen(req, timeout=30) as resp:
return json.loads(resp.read())
except HTTPError as e:
print(f"[ERROR] GitHub API {method} {path}: {e.code} — {e.read().decode('utf-8', errors='replace')}")
print(f"[ERROR] Gitea API GET {path}: {e.code} — {e.read().decode('utf-8', errors='replace')}")
raise
except URLError as e:
print(f"[ERROR] GitHub API {method} {path}: {e}")
print(f"[ERROR] Gitea API GET {path}: {e}")
raise
def _gh_search(query: str, token: str, kind: str = "issues") -> list:
"""Run a GitHub search. Returns the items list (paginated, capped at 100)."""
result = _gh_api(f"/search/{kind}", token, params={"q": query, "per_page": 100})
if isinstance(result, dict):
return result.get("items", [])
return []
def _gitea_paged(base: str, path: str, token: str, params: dict | None = None) -> list:
"""Collect every page of a Gitea listing endpoint (stops at the first empty page)."""
items: list = []
for page in range(1, GITEA_MAX_PAGES + 1):
batch = _gitea_api(base, path, token, {**(params or {}), "page": page, "limit": GITEA_PAGE_LIMIT})
if not isinstance(batch, list) or not batch:
return items
items.extend(batch)
print(f"[WARN] {path}: stopped after {GITEA_MAX_PAGES} pages ({len(items)} items).")
return items
def _parse_ts(value: str | None) -> datetime | None:
"""Parse an RFC 3339 timestamp from the API (None when missing or invalid)."""
if not value:
return None
try:
return datetime.fromisoformat(value.replace("Z", "+00:00"))
except ValueError:
return None
def _truncate(text: str, limit: int, suffix: str = "…") -> str:
@@ -401,182 +428,72 @@ def post_release_build() -> int:
return 0 if _post_webhook(webhook, {"username": "Build Bot", "embeds": [embed]}) else 1
# ---------- Phase 2: Dependabot consolidator ----------
def _list_org_repos(owner: str, token: str) -> list[dict]:
"""List all repos owned by `owner` (user or org). Paginated, capped at 200."""
repos: list[dict] = []
for page in range(1, 3): # 100 per page × 2 pages = 200 max
# `/users/{owner}/repos` works for users; for orgs use `/orgs/{owner}/repos`.
# Try user endpoint first, fall back to org if 404.
try:
page_repos = _gh_api(f"/users/{owner}/repos", token, params={"per_page": 100, "page": page, "type": "owner"})
except HTTPError:
page_repos = _gh_api(f"/orgs/{owner}/repos", token, params={"per_page": 100, "page": page})
if not isinstance(page_repos, list) or not page_repos:
break
repos.extend(page_repos)
if len(page_repos) < 100:
break
return repos
def post_dependabot_summary() -> int:
"""
Daily Dependabot summary across all repos.
Lists open PRs authored by 'dependabot[bot]', grouped by repo. If zero PRs,
posts a quiet 'all clean' message (configurable).
Env:
DISCORD_DEPENDABOT_WEBHOOK — webhook for #dependabot
OPS_GH_TOKEN — PAT with `repo` scope (or fine-grained read across all repos)
GH_OWNER — GitHub username (e.g. 'poli0981')
QUIET_WHEN_EMPTY — 'true' to skip posting when zero PRs (default: false)
"""
webhook = _required("DISCORD_DEPENDABOT_WEBHOOK")
token = _required("OPS_GH_TOKEN")
owner = _required("GH_OWNER")
quiet_when_empty = _env("QUIET_WHEN_EMPTY", "false").lower() == "true"
# Use search API to find all open dependabot PRs across owner's repos in one call.
# Search is rate-limited at 30 req/min for authenticated users — well under that.
query = f"is:open is:pr author:app/dependabot user:{owner}"
print(f"[INFO] Searching: {query}")
items = _gh_search(query, token)
print(f"[INFO] Found {len(items)} open Dependabot PR(s).")
if not items and quiet_when_empty:
print("[INFO] No PRs and QUIET_WHEN_EMPTY=true; skipping post.")
return 0
# Group by repo
by_repo: dict[str, list[dict]] = defaultdict(list)
for item in items:
# repository_url is "https://api.github.com/repos/{owner}/{name}"
repo_url = item.get("repository_url", "")
repo_full = repo_url.rsplit("/repos/", 1)[-1] if "/repos/" in repo_url else "unknown"
by_repo[repo_full].append(item)
fields = []
for repo_full in sorted(by_repo.keys()):
prs = by_repo[repo_full]
# Sort: oldest first within a repo, so stale ones are visible
prs.sort(key=lambda p: p.get("created_at", ""))
lines = []
for pr in prs[:5]: # cap per repo to keep field under 1024
title = _truncate(pr.get("title", ""), 80)
number = pr.get("number", "?")
url = pr.get("html_url", "")
created = pr.get("created_at", "")
try:
age_days = (datetime.now(timezone.utc) - datetime.fromisoformat(created.replace("Z", "+00:00"))).days
age_str = f" ({age_days}d)" if age_days >= 1 else " (today)"
except (ValueError, AttributeError):
age_str = ""
lines.append(f"• [#{number}]({url}) {title}{age_str}")
if len(prs) > 5:
lines.append(f"• … +{len(prs) - 5} more")
fields.append({
"name": f"{repo_full} ({len(prs)})",
"value": _truncate("\n".join(lines), MAX_FIELD_VALUE),
"inline": False,
})
# Discord caps embeds at 25 fields; truncate gracefully
if len(fields) >= 24 and len(by_repo) > 24:
remaining_repos = len(by_repo) - 24
remaining_prs = sum(len(by_repo[r]) for r in sorted(by_repo.keys())[24:])
fields.append({
"name": "…and more",
"value": f"+{remaining_prs} PR(s) in {remaining_repos} other repo(s)",
"inline": False,
})
break
if items:
title = f"🤖 Dependabot: {len(items)} open PR(s) across {len(by_repo)} repo(s)"
description = "Daily summary of open dependency-update PRs."
else:
title = "🤖 Dependabot: all clean"
description = "No open dependency-update PRs across any repo. ✨"
embed = {
"title": title,
"description": description,
"color": COLOR_DEPENDABOT,
"fields": fields,
"footer": {"text": f"{owner} • daily summary"},
"timestamp": datetime.now(timezone.utc).isoformat(),
}
return 0 if _post_webhook(webhook, {"username": "Dependabot Digest", "embeds": [embed]}) else 1
# ---------- Phase 2: Weekly digest ----------
def post_weekly_digest() -> int:
"""
Weekly activity digest. Aggregates last 7 days of:
Weekly activity digest (Gitea). Aggregates the last 7 days of:
- merged PRs
- closed issues
- releases published
- commits to default branches
Posted to #announcements (configurable).
across the repos owned by GH_OWNER and posts it to #announcements (configurable).
Env:
DISCORD_DIGEST_WEBHOOK — webhook for #announcements
OPS_GH_TOKEN — PAT with read access
GH_OWNER — owner username
OPS_GITEA_TOKEN — Gitea PAT, scopes read:repository + read:issue
(the job token only sees its own repo)
GH_OWNER — owner username (default: owner part of GITHUB_REPOSITORY)
GITEA_API_URL — API root, e.g. https://git.poli0981.dev/api/v1
(default: GITHUB_SERVER_URL + /api/v1)
"""
webhook = _required("DISCORD_DIGEST_WEBHOOK")
token = _required("OPS_GH_TOKEN")
owner = _required("GH_OWNER")
token = _required("OPS_GITEA_TOKEN")
owner = _env("GH_OWNER") or _required("GITHUB_REPOSITORY").split("/", 1)[0]
base = _gitea_api_base()
since = (datetime.now(timezone.utc) - timedelta(days=7)).strftime("%Y-%m-%d")
print(f"[INFO] Aggregating activity since {since} for {owner}")
# Use search for merged PRs and closed issues — fastest cross-repo aggregation
merged_prs = _gh_search(f"user:{owner} is:pr is:merged merged:>={since}", token)
closed_issues = _gh_search(f"user:{owner} is:issue is:closed closed:>={since}", token)
# Releases: list per repo via the repos endpoint, filter by published_at locally.
# GitHub search doesn't index releases, so this is unavoidable.
repos = _list_org_repos(owner, token)
releases_by_repo: dict[str, list[dict]] = defaultdict(list)
since_dt = datetime.now(timezone.utc) - timedelta(days=7)
since = since_dt.strftime("%Y-%m-%d")
since_rfc3339 = since_dt.strftime("%Y-%m-%dT%H:%M:%SZ")
print(f"[INFO] Aggregating activity since {since_rfc3339} for {owner} via {base}")
def in_window(value: str | None) -> bool:
ts = _parse_ts(value)
return ts is not None and ts >= since_dt
# Issue search filters on "updated since"; merged_at / closed_at are checked locally.
search = {"owner": owner, "state": "closed", "since": since_rfc3339}
merged_prs = [
p for p in _gitea_paged(base, "/repos/issues/search", token, {**search, "type": "pulls"})
if (p.get("pull_request") or {}).get("merged") and in_window((p.get("pull_request") or {}).get("merged_at"))
]
closed_issues = [
i for i in _gitea_paged(base, "/repos/issues/search", token, {**search, "type": "issues"})
if in_window(i.get("closed_at"))
]
# Releases: no cross-repo endpoint, so list them per repo and filter by published_at.
repos = _gitea_paged(base, f"/users/{quote(owner, safe='')}/repos", token)
releases_by_repo: dict[str, list[dict]] = defaultdict(list)
for repo in repos:
repo_full = repo.get("full_name", "")
if repo.get("archived") or repo.get("disabled"):
# archived: frozen; mirror: someone else's activity; empty: nothing to release
if not repo_full or repo.get("archived") or repo.get("mirror") or repo.get("empty"):
continue
try:
rels = _gh_api(f"/repos/{repo_full}/releases", token, params={"per_page": 10})
if isinstance(rels, list):
for r in rels:
pub = r.get("published_at")
if not pub:
continue
try:
pub_dt = datetime.fromisoformat(pub.replace("Z", "+00:00"))
except ValueError:
continue
if pub_dt >= since_dt:
releases_by_repo[repo_full].append(r)
rels = _gitea_api(base, f"/repos/{quote(repo_full, safe='/')}/releases", token,
{"limit": 10, "draft": "false"})
except HTTPError:
continue # skip repos we can't read
if isinstance(rels, list):
for r in rels:
if not r.get("draft") and in_window(r.get("published_at")):
releases_by_repo[repo_full].append(r)
# Top-active repos (by PR + issue count)
repo_activity: dict[str, int] = defaultdict(int)
for pr in merged_prs:
repo_full = pr.get("repository_url", "").rsplit("/repos/", 1)[-1]
repo_activity[repo_full] += 1
for iss in closed_issues:
repo_full = iss.get("repository_url", "").rsplit("/repos/", 1)[-1]
for item in merged_prs + closed_issues:
repo_full = (item.get("repository") or {}).get("full_name") or "unknown"
repo_activity[repo_full] += 1
fields = []
@@ -635,7 +552,7 @@ def post_weekly_digest() -> int:
def main() -> int:
if len(sys.argv) < 2:
print("Usage: discord_notify.py <release|failure|deploy|release-build|dependabot-summary|weekly-digest>")
print("Usage: discord_notify.py <release|failure|deploy|release-build|weekly-digest>")
return 2
cmd = sys.argv[1].lower()
@@ -644,7 +561,6 @@ def main() -> int:
"failure": post_failure,
"deploy": post_deploy,
"release-build": post_release_build,
"dependabot-summary": post_dependabot_summary,
"weekly-digest": post_weekly_digest,
}
handler = handlers.get(cmd)
-65
View File
@@ -1,65 +0,0 @@
name: Reusable — CodeQL with Build (C#/.NET)
# Reusable CodeQL for C#/.NET. Includes restore + build before analyze.
on:
workflow_call:
inputs:
dotnet_version:
description: ".NET SDK version (e.g., 8.0.x, 9.0.x, 11.0.x)"
type: string
required: true
queries:
description: "CodeQL query suite"
type: string
default: "security-extended"
build_args:
description: "Extra args for dotnet build"
type: string
default: '/p:UseAppHost=false'
timeout_minutes:
description: "Job timeout"
type: number
default: 30
permissions:
actions: read
contents: read
security-events: write
jobs:
analyze:
name: Analyze (csharp)
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout_minutes }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ inputs.dotnet_version }}
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: csharp
queries: ${{ inputs.queries }}
- name: Build
run: |
set -euo pipefail
SLN=$(find . -maxdepth 2 -name '*.sln' | head -1)
if [ -n "$SLN" ]; then
dotnet restore "$SLN"
dotnet build "$SLN" --configuration Release --no-restore ${{ inputs.build_args }}
else
echo "::warning::No .sln found; falling back to autobuild"
exit 1
fi
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:csharp"
-89
View File
@@ -1,89 +0,0 @@
name: CodeQL
# Multi-language CodeQL for repos with mixed stack.
# Use this for: free-steam-games-list (Python + TS + Rust),
# free-games-itchio-list (Python + TS + Rust).
#
# Matrix splits each language into a separate parallel job — failures in
# one language don't block the others.
on:
push:
branches: [main, master]
paths:
- 'scripts/**'
- 'web/src/**'
- 'webapp/src/**'
- 'web/src-tauri/**'
- 'webapp/src-tauri/**'
- '**/*.py'
- '**/*.ts'
- '**/*.tsx'
- '**/*.js'
- '**/*.jsx'
- '**/*.rs'
- 'requirements.txt'
- 'package.json'
- 'package-lock.json'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/codeql.yml'
pull_request:
branches: [main, master]
paths:
- 'scripts/**'
- 'web/src/**'
- 'webapp/src/**'
- 'web/src-tauri/**'
- 'webapp/src-tauri/**'
- '**/*.py'
- '**/*.ts'
- '**/*.tsx'
- '**/*.js'
- '**/*.jsx'
- '**/*.rs'
schedule:
- cron: '0 14 * * 1'
workflow_dispatch:
permissions:
actions: read
contents: read
security-events: write
concurrency:
group: codeql-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
# Note: Rust support in CodeQL is in beta as of 2026 — toggle the
# 'rust' entry off if your CodeQL setup doesn't recognize it yet.
language: ['python', 'javascript-typescript']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
if: matrix.language == 'python'
uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
queries: security-extended
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{ matrix.language }}"
-69
View File
@@ -1,69 +0,0 @@
name: Reusable — CodeQL Analysis (no build)
# Reusable CodeQL for languages that don't need a build step:
# Python, JavaScript/TypeScript.
#
# For C# / Java / etc., use codeql-build.yml which adds a build step.
#
# Caller minimum:
# on:
# push:
# branches: [main]
# paths: ['**/*.py', '**/*.ts', ...]
# schedule: [{cron: '0 14 * * 1'}]
# jobs:
# analyze:
# uses: poli0981/.github/.github/workflows/codeql.yml@main
# with:
# language: python # or 'javascript-typescript'
on:
workflow_call:
inputs:
language:
description: "CodeQL language: python | javascript-typescript"
type: string
required: true
python_version:
description: "Python version (only used when language=python)"
type: string
default: "3.12"
queries:
description: "CodeQL query suite"
type: string
default: "security-extended"
timeout_minutes:
description: "Job timeout"
type: number
default: 15
permissions:
actions: read
contents: read
security-events: write
jobs:
analyze:
name: Analyze (${{ inputs.language }})
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout_minutes }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Python
if: inputs.language == 'python'
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python_version }}
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ inputs.language }}
queries: ${{ inputs.queries }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{ inputs.language }}"
-56
View File
@@ -1,56 +0,0 @@
name: Dependabot Daily Summary
# Lives in poli0981/.github (or any ops repo).
# Runs daily, queries GitHub for open Dependabot PRs across all your repos,
# posts a single summary to #dependabot.
#
# Required repo secrets (set on poli0981/.github):
# DISCORD_DEPENDABOT_WEBHOOK — webhook for #dependabot
# OPS_GH_TOKEN — fine-grained PAT, see SETUP below
#
# SETUP — create OPS_GH_TOKEN:
# 1. https://github.com/settings/personal-access-tokens/new
# 2. Resource owner: your username
# 3. Repository access: All repositories (or select Tier-1/2/3 repos)
# 4. Permissions:
# - Pull requests: Read
# - Metadata: Read (auto-included)
# - Issues: Read (only needed for the weekly digest workflow)
# - Contents: Read (only needed for the weekly digest workflow)
# 5. Expire: 90 days (set a calendar reminder to rotate)
# 6. Save the token, paste into OPS_GH_TOKEN secret
#
# To run on demand: Actions tab → Dependabot Daily Summary → Run workflow
on:
schedule:
# 13:00 UTC = 20:00 ICT — fits before your 21:00 wind-down block
- cron: "0 13 * * *"
workflow_dispatch:
inputs:
quiet_when_empty:
description: "Skip posting if zero PRs?"
type: boolean
default: false
permissions:
contents: read
jobs:
summary:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
with:
sparse-checkout: |
.github/scripts
sparse-checkout-cone-mode: false
- name: Post Dependabot summary
env:
DISCORD_DEPENDABOT_WEBHOOK: ${{ secrets.DISCORD_DEPENDABOT_WEBHOOK }}
OPS_GH_TOKEN: ${{ secrets.OPS_GH_TOKEN }}
GH_OWNER: ${{ github.repository_owner }}
QUIET_WHEN_EMPTY: ${{ inputs.quiet_when_empty || 'false' }}
run: python .github/scripts/discord_notify.py dependabot-summary
-63
View File
@@ -1,63 +0,0 @@
# Reusable CI for Assembly projects (x86-64 Linux)
# Make-driven: repo provides a Makefile; workflow installs the assembler and runs it.
# NOTE: CodeQL does NOT support Assembly, Dependabot has no ASM ecosystem —
# this repo type gets CI + github-actions Dependabot only.
#
# Verified 2026-07-06: ubuntu-latest = Ubuntu 24.04 (GAS/binutils + GNU Make preinstalled;
# NASM installed via apt), checkout v7
name: Reusable / Assembly
on:
workflow_call:
inputs:
assembler:
description: "'nasm' (installed via apt) | 'gas' (binutils, preinstalled)"
type: string
default: 'nasm'
build-command:
type: string
default: 'make'
run-tests:
type: boolean
default: true
test-command:
type: string
default: 'make test'
jobs:
build-test:
runs-on: ubuntu-latest # = Ubuntu 24.04 LTS (x86-64)
timeout-minutes: 15
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Install NASM
if: ${{ inputs.assembler == 'nasm' }}
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq nasm
nasm -v
- name: Toolchain info
run: |
as --version | head -1
ld --version | head -1
make --version | head -1
- name: Build
run: ${{ inputs.build-command }}
- name: Test
if: ${{ inputs.run-tests }}
run: |
if [ "${{ inputs.test-command }}" != "make test" ]; then
${{ inputs.test-command }}
elif make -n test >/dev/null 2>&1; then
make test
else
echo "No test target — skipping"
fi
@@ -1,151 +0,0 @@
# Reusable CI/CD for Chrome extensions (Manifest V3)
# Supports two modes:
# package-manager: 'none' → zero-npm-dependency vanilla extensions (syntax check + zip)
# package-manager: 'npm' | 'pnpm' → built extensions (WXT + Svelte 5 + TS, etc.)
#
# Verified 2026-07-06: Node 24 = active LTS (until Oct 2026, EOL Apr 2028),
# ubuntu-latest = Ubuntu 24.04, checkout v7, setup-node v6, upload-artifact v7, pnpm/action-setup v6
name: Reusable / Chrome Extension
on:
workflow_call:
inputs:
package-manager:
description: "'none' (vanilla, zero deps) | 'npm' | 'pnpm'"
type: string
default: 'none'
node-version:
type: string
default: '24' # Node 24 = active LTS
build-command:
description: 'Build command when package-manager != none'
type: string
default: 'npm run build'
source-dir:
description: 'Directory containing manifest.json to package (vanilla: ".", WXT: ".output/chrome-mv3")'
type: string
default: '.'
release:
description: 'true = attach zip to GitHub Release (call from tag workflow)'
type: boolean
default: false
jobs:
build:
if: ${{ !inputs.release }}
runs-on: ubuntu-latest # = Ubuntu 24.04 LTS
timeout-minutes: 15
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup pnpm
if: ${{ inputs.package-manager == 'pnpm' }}
uses: pnpm/action-setup@v6
- name: Setup Node.js ${{ inputs.node-version }}
if: ${{ inputs.package-manager != 'none' }}
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version }}
cache: ${{ inputs.package-manager }}
- name: Install dependencies
if: ${{ inputs.package-manager != 'none' }}
run: |
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm install --frozen-lockfile
else
npm ci
fi
- name: Build
if: ${{ inputs.package-manager != 'none' }}
run: ${{ inputs.build-command }}
- name: Syntax-check vanilla JS modules
if: ${{ inputs.package-manager == 'none' }}
run: |
find "${{ inputs.source-dir }}" -name '*.js' \
-not -path '*/node_modules/*' -not -path '*/.git/*' -print0 \
| xargs -0 -r -n1 node --check
echo "All JS files pass syntax check"
- name: Validate MV3 manifest
run: |
MANIFEST="${{ inputs.source-dir }}/manifest.json"
test -f "$MANIFEST" || { echo "::error::manifest.json not found in ${{ inputs.source-dir }}"; exit 1; }
jq -e '.manifest_version == 3' "$MANIFEST" > /dev/null || { echo "::error::manifest_version must be 3"; exit 1; }
echo "Extension version: $(jq -r '.version' "$MANIFEST")"
- name: Package zip
id: pack
run: |
MANIFEST="${{ inputs.source-dir }}/manifest.json"
VERSION=$(jq -r '.version' "$MANIFEST")
NAME="${GITHUB_REPOSITORY##*/}"
ZIP="${NAME}-v${VERSION}.zip"
(cd "${{ inputs.source-dir }}" && zip -rq "$GITHUB_WORKSPACE/$ZIP" . \
-x '.git/*' -x '.github/*' -x 'node_modules/*' -x 'docs/*' -x '*.zip' -x '*.map')
echo "zip=$ZIP" >> "$GITHUB_OUTPUT"
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: extension-zip
path: ${{ steps.pack.outputs.zip }}
retention-days: 14
release:
if: ${{ inputs.release }}
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup pnpm
if: ${{ inputs.package-manager == 'pnpm' }}
uses: pnpm/action-setup@v6
- name: Setup Node.js ${{ inputs.node-version }}
if: ${{ inputs.package-manager != 'none' }}
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version }}
cache: ${{ inputs.package-manager }}
- name: Install + build
if: ${{ inputs.package-manager != 'none' }}
run: |
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm install --frozen-lockfile
else
npm ci
fi
${{ inputs.build-command }}
- name: Package zip
id: pack
run: |
MANIFEST="${{ inputs.source-dir }}/manifest.json"
VERSION=$(jq -r '.version' "$MANIFEST")
TAG="${GITHUB_REF_NAME#v}"
if [ "$TAG" != "$VERSION" ]; then
echo "::warning::Tag ($TAG) != manifest version ($VERSION)"
fi
NAME="${GITHUB_REPOSITORY##*/}"
ZIP="${NAME}-v${VERSION}.zip"
(cd "${{ inputs.source-dir }}" && zip -rq "$GITHUB_WORKSPACE/$ZIP" . \
-x '.git/*' -x '.github/*' -x 'node_modules/*' -x 'docs/*' -x '*.zip' -x '*.map')
echo "zip=$ZIP" >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create "${{ github.ref_name }}" "${{ steps.pack.outputs.zip }}" --generate-notes
-52
View File
@@ -1,52 +0,0 @@
# Reusable CodeQL analysis for all portfolio languages
# csharp / python / javascript-typescript / ruby → ubuntu-latest, build-mode: none
# c-cpp / java-kotlin / go → ubuntu-latest, build-mode: autobuild
# swift → macos-latest, build-mode: autobuild
#
# NOT supported by CodeQL: PHP, R, Assembly (those repo types get CI + Dependabot only).
# java-kotlin uses autobuild because build-mode "none" only analyzes pure Java, not Kotlin.
#
# Verified 2026-07-06: github/codeql-action v4 (v4.36.3), checkout v7
# NOTE: repo Settings → Advanced Security → CodeQL "Default setup" must be DISABLED,
# otherwise this advanced-setup workflow is rejected at upload time.
name: Reusable / CodeQL
on:
workflow_call:
inputs:
languages:
description: >-
JSON array. Values: "csharp", "python", "javascript-typescript", "ruby",
"c-cpp", "java-kotlin", "go", "swift". Example: '["csharp"]'
type: string
required: true
jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ${{ matrix.language == 'swift' && 'macos-latest' || 'ubuntu-latest' }}
timeout-minutes: 60
permissions:
security-events: write # upload SARIF results
packages: read # fetch internal CodeQL packs
actions: read
contents: read
strategy:
fail-fast: false
matrix:
language: ${{ fromJSON(inputs.languages) }}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ contains(fromJSON('["swift", "c-cpp", "java-kotlin", "go"]'), matrix.language) && 'autobuild' || 'none' }}
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@v4
with:
category: '/language:${{ matrix.language }}'
@@ -1,148 +0,0 @@
# Reusable CI/CD for Windows desktop apps (.NET 10 LTS / WPF / Velopack)
# Lives in: poli0981/.github → called via:
# uses: poli0981/.github/.github/workflows/reusable-desktop-csharp.yml@main
#
# Verified 2026-07-06: .NET 10.0.x = active LTS (10.0.9), windows-latest = Windows Server 2025,
# checkout v7, setup-dotnet v5, upload-artifact v7, Velopack (vpk) 1.2.x
name: Reusable / Desktop C#
on:
workflow_call:
inputs:
solution:
description: 'Path to .sln (empty = auto-detect single solution in root)'
type: string
default: ''
project:
description: 'Main .csproj used for publish + Velopack pack (release only)'
type: string
default: ''
dotnet-version:
description: '.NET SDK version'
type: string
default: '10.0.x' # .NET 10 = current LTS (Nov 2025 → Nov 2028)
configuration:
type: string
default: 'Release'
rid:
description: 'Runtime identifier for publish'
type: string
default: 'win-x64'
run-tests:
type: boolean
default: true
release:
description: 'true = publish + vpk pack + upload to GitHub Releases (call from tag workflow)'
type: boolean
default: false
pack-id:
description: 'Velopack packId (required when release: true)'
type: string
default: ''
main-exe:
description: 'Main exe name; defaults to <pack-id>.exe'
type: string
default: ''
jobs:
build-test:
if: ${{ !inputs.release }}
runs-on: windows-latest # = Windows Server 2025
timeout-minutes: 30
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup .NET ${{ inputs.dotnet-version }}
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ inputs.dotnet-version }}
- name: Restore
run: dotnet restore ${{ inputs.solution }}
- name: Build
run: dotnet build ${{ inputs.solution }} --configuration ${{ inputs.configuration }} --no-restore
- name: Test
if: ${{ inputs.run-tests }}
run: dotnet test ${{ inputs.solution }} --configuration ${{ inputs.configuration }} --no-build --logger "trx;LogFileName=test-results.trx"
- name: Upload test results
if: ${{ inputs.run-tests && always() }}
uses: actions/upload-artifact@v7
with:
name: test-results
path: '**/TestResults/*.trx'
if-no-files-found: ignore
retention-days: 14
release:
if: ${{ inputs.release }}
runs-on: windows-latest
timeout-minutes: 45
permissions:
contents: write # create release + upload assets
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup .NET ${{ inputs.dotnet-version }}
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ inputs.dotnet-version }}
- name: Resolve version from tag
id: ver
shell: pwsh
run: |
$v = "${{ github.ref_name }}" -replace '^v', ''
"version=$v" >> $env:GITHUB_OUTPUT
Write-Host "Release version: $v"
- name: Publish (self-contained, ${{ inputs.rid }})
run: >
dotnet publish ${{ inputs.project }}
--configuration ${{ inputs.configuration }}
--runtime ${{ inputs.rid }}
--self-contained true
--output publish
"/p:Version=${{ steps.ver.outputs.version }}"
- name: Install Velopack CLI
run: dotnet tool install -g vpk
- name: Download previous releases (enables delta packages)
continue-on-error: true # first release has nothing to download
run: >
vpk download github
--repoUrl https://github.com/${{ github.repository }}
--token ${{ secrets.GITHUB_TOKEN }}
--outputDir releases
- name: Velopack pack
shell: pwsh
run: |
$exe = "${{ inputs.main-exe }}"
if (-not $exe) { $exe = "${{ inputs.pack-id }}.exe" }
vpk pack `
--packId "${{ inputs.pack-id }}" `
--packVersion "${{ steps.ver.outputs.version }}" `
--packDir publish `
--mainExe $exe `
--outputDir releases
- name: Upload to GitHub Releases
run: >
vpk upload github
--repoUrl https://github.com/${{ github.repository }}
--token ${{ secrets.GITHUB_TOKEN }}
--publish
--releaseName "${{ inputs.pack-id }} ${{ steps.ver.outputs.version }}"
--tag ${{ github.ref_name }}
--outputDir releases
-68
View File
@@ -1,68 +0,0 @@
# Reusable CI for R projects
# NOTE: CodeQL does NOT support R, and Dependabot has no CRAN ecosystem —
# this repo type gets CI + github-actions Dependabot only.
#
# Verified 2026-07-06: R 4.6.1 = latest release (2026-06-24; 'release' alias resolves to it),
# r-lib/actions v2 (v2.12.1), checkout v7, ubuntu-latest = Ubuntu 24.04
name: Reusable / R
on:
workflow_call:
inputs:
r-version:
description: "'release' = always latest R release; or pin e.g. '4.6.1'"
type: string
default: 'release'
type:
description: "'package' = R CMD check via r-lib | 'scripts' = run a test script"
type: string
default: 'package'
test-script:
description: 'Entry script for scripts mode (run if it exists)'
type: string
default: 'tests/run_tests.R'
jobs:
check:
runs-on: ubuntu-latest # = Ubuntu 24.04 LTS
timeout-minutes: 30
permissions:
contents: read
env:
R_KEEP_PKG_SOURCE: yes
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup R (${{ inputs.r-version }})
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ inputs.r-version }}
use-public-rspm: true # binary packages from Posit PPM = much faster installs
# --- R package path: dependency install + R CMD check ---
- name: Install package dependencies
if: ${{ inputs.type == 'package' }}
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check
- name: R CMD check
if: ${{ inputs.type == 'package' }}
uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
# --- Scripts path: run test entry script if present ---
- name: Run test script
if: ${{ inputs.type == 'scripts' }}
run: |
if [ -f "${{ inputs.test-script }}" ]; then
Rscript "${{ inputs.test-script }}"
else
echo "No ${{ inputs.test-script }} — running syntax parse check on all .R files"
find . -name '*.R' -not -path './.git/*' -print0 \
| xargs -0 -r -n1 -I{} Rscript -e 'invisible(parse("{}"))'
fi
-141
View File
@@ -1,141 +0,0 @@
# Reusable CI + GitHub Pages deploy for web apps (React 19 / Vite / TypeScript / Vitest)
# Lint / typecheck / test steps run only when the matching npm script exists — safe across repos.
#
# Verified 2026-07-06: Node 24 = active LTS, ubuntu-latest = Ubuntu 24.04, checkout v7,
# setup-node v6, upload-artifact v7, configure-pages v6, upload-pages-artifact v5, deploy-pages v5
name: Reusable / Web React
on:
workflow_call:
inputs:
node-version:
type: string
default: '24' # Node 24 = active LTS
package-manager:
description: "'npm' | 'pnpm'"
type: string
default: 'npm'
build-command:
type: string
default: 'npm run build'
test-command:
description: 'Runs only if a "test" script exists in package.json'
type: string
default: 'npx vitest run'
dist-dir:
type: string
default: 'dist'
deploy-pages:
description: 'true = build + deploy to GitHub Pages (call from main-branch workflow)'
type: boolean
default: false
jobs:
build:
if: ${{ !inputs.deploy-pages }}
runs-on: ubuntu-latest # = Ubuntu 24.04 LTS
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup pnpm
if: ${{ inputs.package-manager == 'pnpm' }}
uses: pnpm/action-setup@v6
- name: Setup Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version }}
cache: ${{ inputs.package-manager }}
- name: Install dependencies
run: |
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm install --frozen-lockfile
else
npm ci
fi
- name: Lint (if script exists)
run: |
if jq -e '.scripts.lint' package.json > /dev/null; then
${{ inputs.package-manager }} run lint
else
echo "No lint script — skipping"
fi
- name: Typecheck (if script exists)
run: |
if jq -e '.scripts.typecheck' package.json > /dev/null; then
${{ inputs.package-manager }} run typecheck
else
echo "No typecheck script — skipping"
fi
- name: Test (if script exists)
run: |
if jq -e '.scripts.test' package.json > /dev/null; then
${{ inputs.test-command }}
else
echo "No test script — skipping"
fi
- name: Build
run: ${{ inputs.build-command }}
- name: Upload build artifact
uses: actions/upload-artifact@v7
with:
name: dist
path: ${{ inputs.dist-dir }}
retention-days: 14
deploy:
if: ${{ inputs.deploy-pages }}
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
pages: write # deploy to Pages
id-token: write # OIDC token for deployment verification
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup pnpm
if: ${{ inputs.package-manager == 'pnpm' }}
uses: pnpm/action-setup@v6
- name: Setup Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version }}
cache: ${{ inputs.package-manager }}
- name: Install + build
run: |
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm install --frozen-lockfile
else
npm ci
fi
${{ inputs.build-command }}
- name: Configure Pages
uses: actions/configure-pages@v6
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v5
with:
path: ${{ inputs.dist-dir }}
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
-39
View File
@@ -1,39 +0,0 @@
name: Weekly Digest
# Lives in poli0981/.github. Runs every Sunday 21:00 ICT (matches your
# wind-down block). Aggregates last 7 days of activity across all your
# repos and posts a summary to #announcements.
#
# Required repo secrets (set on poli0981/.github):
# DISCORD_DIGEST_WEBHOOK — webhook for #announcements
# OPS_GH_TOKEN — same PAT as Dependabot summary; see that
# workflow's SETUP block for token scopes
#
# Run on demand: Actions tab → Weekly Digest → Run workflow
on:
schedule:
# 14:00 UTC Sunday = 21:00 ICT Sunday
- cron: "0 14 * * 0"
workflow_dispatch:
permissions:
contents: read
jobs:
digest:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
with:
sparse-checkout: |
.github/scripts
sparse-checkout-cone-mode: false
- name: Post weekly digest
env:
DISCORD_DIGEST_WEBHOOK: ${{ secrets.DISCORD_DIGEST_WEBHOOK }}
OPS_GH_TOKEN: ${{ secrets.OPS_GH_TOKEN }}
GH_OWNER: ${{ github.repository_owner }}
run: python .github/scripts/discord_notify.py weekly-digest