Repository navigation
161 lines (140 loc) · 5.88 KB
/
Copy pathdocs.yml
File metadata and controls
161 lines (140 loc) · 5.88 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Docs
# Publishes the contents of the `docs/` folder to GitHub Pages and to the repository wiki.
#
# Runs automatically on documentation changes (`push` to `master`/`main` below), manually from
# the Actions tab ("Run workflow"), or when the Release workflow calls it for a `v*` tag.
on:
workflow_dispatch:
workflow_call:
push:
branches: [ master, main ]
paths:
- 'docs/**'
- 'screenshot*.png'
- 'LICENSE.txt'
- '.github/workflows/docs.yml'
concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: false
env:
DOTNET_NOLOGO: true
permissions:
contents: read
pages: write
id-token: write
jobs:
build-pages:
name: Build Pages site
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Assemble site content
run: |
set -euo pipefail
mkdir -p site
cp -r docs/. site/
# The docs reference files that live one level above the docs folder with "../".
# Copying them to the site root keeps those relative links working.
for file in screenshot.png screenshot2.png screenshot3.png screenshot4.png LICENSE.txt; do
if [ -f "$file" ]; then
cp "$file" site/
fi
done
# GitHub Pages' jekyll-optional-front-matter plugin denylists community files such
# as CONTRIBUTING unless they carry YAML front matter, which would leave
# contributing.md as a raw download. Add the front matter to the site copy only so
# the wiki copy stays plain markdown.
if [ -f site/contributing.md ] && [ "$(head -n 1 site/contributing.md)" != "---" ]; then
{ printf -- '---\nlayout: default\n---\n\n'; cat site/contributing.md; } > site/contributing.tmp
mv site/contributing.tmp site/contributing.md
fi
- name: Configure Pages
uses: actions/configure-pages@v5
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./site
destination: ./_site
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./_site
deploy-pages:
name: Deploy Pages
runs-on: ubuntu-latest
needs: build-pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
publish-wiki:
name: Publish Wiki
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Sync docs to the wiki
env:
# A classic PAT with the "repo" scope in a WIKI_TOKEN secret is recommended because
# the default GITHUB_TOKEN may not be allowed to push to the wiki repository.
# github.token works both for standalone runs and when called from the Release workflow.
WIKI_TOKEN: ${{ secrets.WIKI_TOKEN || github.token }}
REPO: ${{ github.repository }}
BRANCH: ${{ github.event.repository.default_branch || 'master' }}
run: |
set -euo pipefail
if [ -z "${WIKI_TOKEN}" ]; then
echo "::error::No token available to publish the wiki. Add a WIKI_TOKEN secret (PAT with repo scope)."
exit 1
fi
# The wiki git repository only exists after the wiki is enabled and its first page
# has been created in the GitHub UI.
if ! git clone --depth 1 "https://x-access-token:${WIKI_TOKEN}@github.com/${REPO}.wiki.git" wiki; then
echo "::error::Could not clone ${REPO}.wiki.git. Enable the wiki and create the first page, then re-run this workflow."
exit 1
fi
# Replace the synced markdown pages, keeping any hand-written navigation pages.
find wiki -maxdepth 1 -name '*.md' ! -name '_Sidebar.md' ! -name '_Footer.md' -delete
cp docs/*.md wiki/
mv wiki/README.md wiki/Home.md
# Rewrite docs links for the wiki: page.md -> page, README.md -> Home, and files
# that live outside the docs folder -> absolute GitHub URLs.
find wiki -maxdepth 1 -name '*.md' -print0 | xargs -0 -r sed -i -E \
-e "s@\]\(\.\./screenshot\.png\)@](https://raw.githubusercontent.com/${REPO}/${BRANCH}/screenshot.png)@g" \
-e "s@\]\(\.\./screenshot2\.png\)@](https://raw.githubusercontent.com/${REPO}/${BRANCH}/screenshot2.png)@g" \
-e "s@\]\(\.\./screenshot3\.png\)@](https://raw.githubusercontent.com/${REPO}/${BRANCH}/screenshot3.png)@g" \
-e "s@\]\(\.\./screenshot4\.png\)@](https://raw.githubusercontent.com/${REPO}/${BRANCH}/screenshot4.png)@g" \
-e "s@\]\(\.\./LICENSE\.txt\)@](https://github.com/${REPO}/blob/${BRANCH}/LICENSE.txt)@g" \
-e "s@\]\(README\.md(#[^)]*)?\)@](Home\1)@g" \
-e "s@\]\(([A-Za-z0-9_-]+)\.md(#[^)]*)?\)@](\1\2)@g"
# Create a sidebar on the first run; later runs keep an existing one.
if [ ! -f wiki/_Sidebar.md ]; then
cat > wiki/_Sidebar.md <<'EOF'
**[RVZStudio](Home)**
* [Getting Started](getting-started)
* [User Guide](user-guide)
* [Settings Reference](settings-reference)
* [Troubleshooting](troubleshooting)
* [FAQ](faq)
* [What's New](WhatsNew)
* [Architecture](architecture)
* [Building](building)
* [Contributing](contributing)
EOF
fi
cd wiki
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
if git diff --cached --quiet; then
echo "Wiki is already up to date."
else
git commit -m "Sync wiki from docs/"
git push
fi