Skip to content

Instantly share code, notes, and snippets.

@TwistedAsylumMC
Created July 29, 2022 21:58
Show Gist options
  • Save TwistedAsylumMC/3f03de834d2b1f61a49a353b7de39852 to your computer and use it in GitHub Desktop.
Save TwistedAsylumMC/3f03de834d2b1f61a49a353b7de39852 to your computer and use it in GitHub Desktop.
A github action to use a repository as a mirror of a wiki, allowing for quality control over community contributions.
name: Mirror to wiki
on: [push]
jobs:
mirror:
name: Mirror
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Checkout current repository
uses: actions/checkout@v2
with:
path: ./mirror
- name: Checkout wiki repository
uses: actions/checkout@master
with:
repository: username/repo.wiki # Update this to your username and repo
token: ${{ secrets.ACTIONS_SECRET }} # Personal access token with push access to the repo
path: ./wiki
- name: Remove ignored files
run: |
cd mirror
IGNORE=$(cat .wikiignore) # Optional .wikiignore file that lists the files to be ignored when mirroring
rm -rf $IGNORE
cd ..
- name: Apply changes
run: |
cp -a mirror/. wiki
- name: Push changes
run: |
cd wiki
git add .
git config user.name github-actions
git config user.email github-actions@github.com
git commit -am "${{ github.event.head_commit.message }} (@${{ github.event.head_commit.author.name }})"
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment