-
Notifications
You must be signed in to change notification settings - Fork 1.4k
60 lines (50 loc) · 1.75 KB
/
Copy pathauto-backup-wiki.yml
File metadata and controls
60 lines (50 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Auto backup Wiki
on:
workflow_dispatch:
schedule:
# GitHub Wiki 没有可供 Actions 直接订阅的变更事件,保留低频轮询作为兜底。
- cron: '17 */2 * * *'
permissions:
actions: write
contents: write
concurrency:
group: main-writers
jobs:
backup-wiki-root:
if: github.repository == 'Aethersailor/Custom_OpenClash_Rules'
runs-on: ubuntu-latest
steps:
- name: Checkout main branch for wiki backup
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: main
fetch-depth: 0
- name: Clone wiki repository with auth
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git clone "https://x-access-token:${TOKEN}@github.com/${{ github.repository }}.wiki.git" _wiki
- name: Build and validate Wiki backup
run: |
python .github/scripts/wiki_backup.py \
--source _wiki \
--destination "$RUNNER_TEMP/wiki-backup" \
--repository "${GITHUB_REPOSITORY}"
- name: Replace validated Wiki Markdown backup
run: |
mkdir -p wiki
find wiki -maxdepth 1 -type f -name '*.md' -delete
cp "$RUNNER_TEMP"/wiki-backup/*.md wiki/
- name: Commit and push changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add wiki
if ! git diff --cached --quiet; then
git commit -m "chore(wiki): auto backup Wiki"
git pull --rebase origin main
git push origin HEAD:main
gh workflow run pages.yml --ref main
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}