Skip to content

Fix one overzealous rename of master to main -- the wiki relies on a #18

Fix one overzealous rename of master to main -- the wiki relies on a

Fix one overzealous rename of master to main -- the wiki relies on a #18

Workflow file for this run

name: Wiki
on:
push:
branches: [main]
paths: [wiki/**, .github/workflows/Wiki.yaml]
pull_request:
branches: [main]
paths: [wiki/**, .github/workflows/Wiki.yaml]
permissions:
contents: write
jobs:
check_directories:
name: "Audit changes"
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Ensuring no new directories in ./wiki/"
run: |
if git diff --name-only --diff-filter=A origin/main... | grep -q '^wiki/.*/'; then
echo "New directory detected in wiki folder. This is not allowed."
exit 1
fi
- name: "Ensure edit disclaimers were not manually added"
run: |
notice='Warning: Wiki should not be edited directly'
if grep -r "$notice" wiki; then
echo "Edit disclaimers are automatically prepended. Please remove those manually added."
exit 1
fi
wiki:
name: "Publish changes"
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
with: # Fetch enough history to resolve HEAD^ -- https://github.com/actions/checkout?tab=readme-ov-file#checkout-head
fetch-depth: 2
- name: "Configure git client"
run: |
git config --global user.name "${{ secrets.BOT_NAME }}"
git config --global user.email "${{ secrets.BOT_EMAIL }}"
- name: "Prepend wiki edit warnings"
run: |
notice='_Warning: Wiki should not be edited directly. Edit the files in the ./wiki/ folder instead and make a PR._'
for file in wiki/*.md; do
[ "$(basename "$file")" = "_Sidebar.md" ] && continue
sed -i '1s|^|'"$notice"'\n\n|' "$file"
done
- name: "Clone .wiki repository"
run: |
git clone https://x-access-token:${{ secrets.BOT_TOKEN }}@github.com/${{ github.repository }}.wiki.git
- name: "Update ~.wiki.git contents"
run: |
rsync -av --delete --exclude '.git' wiki/ ${GITHUB_REPOSITORY##*/}.wiki/
- name: "Commit and push changes"
run: |
cd ${GITHUB_REPOSITORY##*/}.wiki
git add .
if [ -n "$(git status --porcelain)" ]; then
git commit -m "Update wiki content at ${{ github.sha }}"
git push origin master
else
echo "No changes to commit"
fi