Skip to content

Instantly share code, notes, and snippets.

@Purpzie
Created September 4, 2023 17:19
Show Gist options
  • Save Purpzie/4c4f4df0c6d912ecbf469aed9241a598 to your computer and use it in GitHub Desktop.
Save Purpzie/4c4f4df0c6d912ecbf469aed9241a598 to your computer and use it in GitHub Desktop.
Sync a wiki with a folder in a repository
name: wiki
on:
push:
branches:
- main
paths:
- wiki/**
- .github/workflows/wiki.yml
concurrency:
group: wiki
cancel-in-progress: true
permissions:
contents: write
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Push to wiki
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |-
gh auth setup-git
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
cd wiki
git init
git add -A
git commit --allow-empty-message -m ''
git remote add origin "${{ github.server_url }}/${{ github.repository }}.wiki.git"
WIKI_BRANCH="$(git remote show origin | grep "HEAD branch" | sed 's/.*: //')"
git branch -M $WIKI_BRANCH
git push -f -u origin $WIKI_BRANCH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment