2023-04-21 02:41:47 +00:00
|
|
|
name: Publish docs to Wiki
|
|
|
|
|
2023-04-21 03:13:45 +00:00
|
|
|
# Trigger this action only if there are changes pushed to the doc/** directory under the main branch
|
2023-04-21 02:41:47 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
paths:
|
|
|
|
- doc/** # This includes all sub folders
|
|
|
|
branches:
|
2023-05-14 08:27:23 +00:00
|
|
|
- main # This can be changed to any branch of your preference
|
2023-04-21 02:41:47 +00:00
|
|
|
|
2024-07-01 13:32:02 +00:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
logLevel:
|
|
|
|
description: 'Log level'
|
|
|
|
required: true
|
|
|
|
default: 'warning'
|
|
|
|
|
2023-04-21 02:41:47 +00:00
|
|
|
env:
|
2023-04-24 04:45:17 +00:00
|
|
|
USER_TOKEN: ${{ secrets.GH_WIKI_PAT }} # This is the repository secret personal access token
|
2023-04-21 13:03:09 +00:00
|
|
|
USER_NAME: ${{ vars.BOT_USER_NAME }} # Enter the username of your (bot) account
|
2023-04-21 02:41:47 +00:00
|
|
|
OWNER: ${{ github.event.repository.owner.name }} # This is the repository owner
|
|
|
|
REPOSITORY_NAME: ${{ github.event.repository.name }} # This is the repository name
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
publish_docs_to_wiki:
|
|
|
|
name: Publish docs to Wiki
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2024-03-10 14:45:35 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-04-21 02:41:47 +00:00
|
|
|
|
2023-04-21 03:13:45 +00:00
|
|
|
# 1. Clone the current wiki master branch to a folder named `tmp_wiki`
|
2023-04-21 02:41:47 +00:00
|
|
|
- name: Pull content from wiki
|
|
|
|
run: |
|
2023-04-21 03:13:45 +00:00
|
|
|
git config --global user.name "$USER_NAME"
|
2023-04-21 13:03:09 +00:00
|
|
|
git config --global user.email "$USER_NAME"@users.noreply.github.com
|
2024-07-01 14:19:03 +00:00
|
|
|
git clone https://"$USER_TOKEN"@github.com/SoftFever/"$REPOSITORY_NAME".wiki.git tmp_wiki
|
2023-04-21 02:58:50 +00:00
|
|
|
# 4. Synchronize differences between `doc` & `tmp_wiki`
|
2023-04-21 02:41:47 +00:00
|
|
|
# 5. Push new Wiki content
|
2023-04-21 03:13:45 +00:00
|
|
|
- name: Push main repo content to wiki
|
2023-04-21 02:41:47 +00:00
|
|
|
run: |
|
2023-04-21 02:58:50 +00:00
|
|
|
rsync -av --delete doc/ tmp_wiki/ --exclude .git
|
2023-04-21 02:41:47 +00:00
|
|
|
cd tmp_wiki
|
|
|
|
git add .
|
2023-04-21 02:58:50 +00:00
|
|
|
git commit -m "Updated Wiki content"
|
2023-04-21 03:13:45 +00:00
|
|
|
git push origin master
|