-
Notifications
You must be signed in to change notification settings - Fork 12
59 lines (48 loc) · 1.59 KB
/
docs.yml
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
name: Generate Docs
on:
push:
branches:
- main
jobs:
docs:
name: Update Docs
runs-on: ubuntu-latest
steps:
- name: "Check out repository"
uses: actions/checkout@v4
- name: Print Rust version
run: rustc -vV
- name: Generate Documentation
run: cargo doc --all-features --no-deps
- name: Generate index file
shell: python3 {0}
run: |
import os
package = os.environ["PACKAGE_NAME"]
assert package
owner, sep, repository = os.environ["GITHUB_REPOSITORY"].partition("/")
assert owner
assert repository
doc = f"""<!DOCTYPE html>
<html>
<head>
<title>Redirecting to https://{owner}.github.io/{repository}/{package}/</title>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; URL=https://{owner}.github.io/{repository}/{package}/">
<link rel="canonical" href="https://{owner}.github.io/{repository}/{package}/">
</head>
</html>"""
output_dir = os.environ["OUTPUT_DIR"]
assert output_dir
output_dir = os.path.join(output_dir, "index.html")
print(f"Writing to {output_dir}")
with open(output_dir, mode="w") as f:
f.write(doc)
env:
PACKAGE_NAME: rekordcrate
OUTPUT_DIR: target/doc
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: target/doc