Files
James Maes 5c2bac9dad ci: add least-privilege permissions to ci and wiki-sync workflows
Set an explicit top-level permissions block (contents: read for CI;
contents: write for wiki-sync, which pushes to the wiki) so the workflows
follow least-privilege and clear the CodeQL 'workflow does not contain
permissions' findings.
2026-07-29 10:36:37 -05:00

51 lines
1.5 KiB
YAML

name: Sync Docs to GitHub Wiki
on:
push:
branches:
- main
paths:
- 'docs/**'
- 'assets/**'
- '.github/workflows/wiki-sync.yml'
workflow_dispatch:
permissions:
contents: write
jobs:
sync-wiki:
name: Sync docs/ to GitHub Wiki
runs-on: ubuntu-latest
steps:
- name: Checkout Main Repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Checkout Wiki Repository
uses: actions/checkout@v7
with:
repository: ${{ github.repository }}.wiki
token: ${{ secrets.GITHUB_TOKEN }}
path: wiki-repo
- name: Sync docs and assets to Wiki (mirror with delete)
run: |
# Mirror docs/ -> wiki so that files removed from docs/ are also removed
# from the wiki. Preserve only the wiki's .git directory.
find wiki-repo -mindepth 1 -maxdepth 1 -not -name '.git' -exec rm -rf {} +
mkdir -p wiki-repo/assets
cp -r docs/* wiki-repo/ 2>/dev/null || true
cp -r assets/* wiki-repo/assets/ 2>/dev/null || true
cd wiki-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
if git diff --staged --quiet; then
echo "No changes to commit to Wiki."
else
git commit -m "docs(wiki): automated sync from docs/ master [skip ci]"
git push origin master
fi