# Copyright (c) 2020-2022 Morwenn
# SPDX-License-Identifier: MIT

name: Wiki Deployment

on:
  push:
    branches:
      - master
    paths:
      - 'docs/**'

jobs:
  sync-wiki-files:
    name: Sync Wiki Files

    runs-on: ubuntu-latest

    steps:
      - name: Checkout /docs
        uses: actions/checkout@v2
        with:
          repository: ${{github.repository}}
          path: main

      - name: Checkout wiki
        uses: actions/checkout@v2
        with:
          repository: ${{github.repository}}.wiki
          path: wiki

      - name: Sync wiki files
        run: |
          find main/docs -name "*.md" -exec sed -i 's/.md)/)/' {} \;
          find main/docs -name "*.md" -exec sed -i 's/.md#/#/' {} \;
          rsync -avzr --delete --exclude='.git/' "main/docs/" "wiki/"

      - name: Commit changes
        working-directory: wiki
        run: |
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git add .
          git commit -m "Synchronize wiki with docs/"

      - name: Push changes to wiki
        uses: ad-m/github-push-action@master
        with:
          directory: wiki
          repository: ${{github.repository}}.wiki
          branch: master

# Copyright (c) 2020-2022 Morwenn
# SPDX-License-Identifier: MIT

name: Wiki Deployment

on:
  push:
    branches:
      - master
    paths:
      - 'docs/**'

jobs:
  sync-wiki-files:
    name: Sync Wiki Files

    runs-on: ubuntu-latest

    steps:
      - name: Checkout /docs
        uses: actions/checkout@v2
        with:
          repository: ${{github.repository}}
          path: main

      - name: Checkout wiki
        uses: actions/checkout@v2
        with:
          repository: ${{github.repository}}.wiki
          path: wiki

      - name: Sync wiki files
        run: |
          for docname in main/docs/*.md; do
            old=$(basename "$docname");
            new=${old%.*};
            find main/docs -name "*.md" -exec sed -i "s/$old/$new/g" {} \;
          done
          rsync -avzr --delete --exclude='.git/' "main/docs/" "wiki/"

      - name: Commit changes
        working-directory: wiki
        run: |
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git add .
          git commit -m "Synchronize wiki with docs/"

      - name: Push changes to wiki
        uses: ad-m/github-push-action@master
        with:
          directory: wiki
          repository: ${{github.repository}}.wiki
          branch: master

Replace file names selectively when deploying to wiki
Replace file names selectively when deploying to wiki
