Files
clawsec/.github/workflows/wiki-sync.yml
T
davida-ps 516e8f0428 Codex/fix readme video links (#76)
* fix(readme): use github-safe demo previews and links

* fix(readme): use only github-hosted demo links

* fix(wiki): map wiki root to index

* feat(readme): add lightweight animated gif demo previews

* refactor(wiki): generate Home from INDEX during sync

* fix(ci): remove github token write scopes in workflows

* chore(ci): use existing poll token for write automation
2026-02-25 22:10:52 +02:00

77 lines
2.3 KiB
YAML

name: Sync Wiki
on:
push:
branches: [main]
paths:
- 'wiki/**'
workflow_dispatch:
permissions: read-all
concurrency:
group: wiki-sync
cancel-in-progress: false
jobs:
sync-wiki:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Sync wiki folder to repository wiki
env:
AUTOMATION_TOKEN: ${{ secrets.POLL_NVD_CVES_PAT }}
run: |
set -euo pipefail
if [ ! -d wiki ]; then
echo "::error::wiki/ directory not found"
exit 1
fi
if [ -z "$AUTOMATION_TOKEN" ]; then
echo "::error::Set POLL_NVD_CVES_PAT with repo write permissions."
exit 1
fi
# GitHub Wiki root (/wiki) renders Home.md, not INDEX.md.
# INDEX.md is the canonical source; generate Home.md from it.
if [ ! -f wiki/INDEX.md ]; then
echo "::error::wiki/INDEX.md not found. It is required to generate wiki/Home.md."
exit 1
fi
cp wiki/INDEX.md wiki/Home.md
WIKI_REMOTE="https://x-access-token:${AUTOMATION_TOKEN}@github.com/${{ github.repository }}.wiki.git"
if ! git ls-remote "$WIKI_REMOTE" >/dev/null 2>&1; then
echo "::warning::Wiki remote unavailable (repository wiki may be disabled). Skipping sync."
exit 0
fi
WIKI_TMP="$(mktemp -d)"
trap 'rm -rf "$WIKI_TMP"' EXIT
git clone --depth 1 "$WIKI_REMOTE" "$WIKI_TMP"
rsync -a --delete --exclude '.git/' wiki/ "$WIKI_TMP/"
cd "$WIKI_TMP"
if [ -z "$(git status --porcelain)" ]; then
echo "No wiki changes to sync."
exit 0
fi
WIKI_HEAD_REF="$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null || true)"
if [ -n "$WIKI_HEAD_REF" ]; then
WIKI_BRANCH="${WIKI_HEAD_REF#origin/}"
else
WIKI_BRANCH="master"
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "docs(wiki): sync from ${GITHUB_SHA}"
git push origin HEAD:"$WIKI_BRANCH"