Repository navigation
fix docs #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync wiki | |
| on: | |
| push: | |
| paths: | |
| - 'wiki/**' | |
| - '.github/workflows/sync-wiki.yml' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: music-craft-wiki | |
| cancel-in-progress: false | |
| jobs: | |
| sync: | |
| if: github.ref_name == github.event.repository.default_branch | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Push wiki pages | |
| env: | |
| WIKI_TOKEN: ${{ secrets.WIKI_TOKEN }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [[ -z "$WIKI_TOKEN" ]]; then | |
| echo 'Set the WIKI_TOKEN Actions secret before syncing the wiki.' >&2 | |
| exit 1 | |
| fi | |
| askpass="$RUNNER_TEMP/music-craft-askpass" | |
| cat > "$askpass" <<'EOF' | |
| #!/bin/sh | |
| case "$1" in | |
| *Username*) printf 'x-access-token' ;; | |
| *) printf '%s' "$WIKI_TOKEN" ;; | |
| esac | |
| EOF | |
| chmod 700 "$askpass" | |
| export GIT_ASKPASS="$askpass" GIT_TERMINAL_PROMPT=0 | |
| destination="$RUNNER_TEMP/music-craft-wiki" | |
| git clone "https://github.com/${GITHUB_REPOSITORY}.wiki.git" "$destination" | |
| rsync -a --delete --exclude='.git' "$GITHUB_WORKSPACE/wiki/" "$destination/" | |
| git -C "$destination" add -A | |
| if git -C "$destination" diff --cached --quiet; then | |
| exit 0 | |
| fi | |
| git -C "$destination" -c user.name='DemonZDevelopment' -c user.email='41898282+github-actions[bot]@users.noreply.github.com' commit -m "Sync Music Craft wiki from ${GITHUB_SHA:0:12}" | |
| git -C "$destination" push |