-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (51 loc) · 1.72 KB
/
Copy pathwiki-sync.yml
File metadata and controls
63 lines (51 loc) · 1.72 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
61
62
63
name: Sync wiki
on:
push:
branches: [main]
paths:
- 'wiki/**'
- '.github/workflows/wiki-sync.yml'
workflow_dispatch:
permissions:
contents: write
concurrency:
group: wiki-sync
cancel-in-progress: false
jobs:
sync:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Sync to wiki
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
REPO_URL="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.wiki.git"
if ! git clone --depth 1 "$REPO_URL" wiki-target 2>clone.err; then
if grep -qi "repository not found" clone.err; then
echo "::warning::Wiki repo does not exist yet. Create the first wiki page on github.com, then re-run this workflow."
cat clone.err
exit 0
fi
echo "::error::Failed to clone wiki repo"
cat clone.err
exit 1
fi
git -C wiki-target config user.name "github-actions[bot]"
git -C wiki-target config user.email "github-actions[bot]@users.noreply.github.com"
rsync -a --delete \
--exclude='.git' \
--exclude='README.md' \
wiki/ wiki-target/
if [ -z "$(git -C wiki-target status --porcelain)" ]; then
echo "No wiki changes to sync."
exit 0
fi
git -C wiki-target add -A
git -C wiki-target commit -m "Sync wiki from wiki/ @ ${GITHUB_SHA::7}
Source: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}"
git -C wiki-target push origin HEAD
echo "Wiki synced."