-
-
Notifications
You must be signed in to change notification settings - Fork 7
128 lines (110 loc) · 4.28 KB
/
docs.yml
File metadata and controls
128 lines (110 loc) · 4.28 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
name: Documentation
on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
jobs:
build-docs:
name: Build Documentation
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: "6.1"
- name: Build Documentation
run: make docs-generate REPO_NAME=math DOCS_VERSION_PATH=main
- name: Setup Redirects
run: |
# Function to create a redirect file
create_redirect() {
local FILE_PATH=$1
local TARGET_URL=$2
local TITLE=$3
mkdir -p "$(dirname "$FILE_PATH")"
cat <<EOF > "$FILE_PATH"
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>$TITLE</title>
<link rel="canonical" href="$TARGET_URL">
<script>
window.location.href = "$TARGET_URL" + window.location.hash;
</script>
<meta http-equiv="refresh" content="0;url=$TARGET_URL">
</head>
<body>
<p>Redirecting to <a href="$TARGET_URL">$TITLE</a>...</p>
</body>
</html>
EOF
}
# 1. Root -> latest/documentation/fireblademath/
create_redirect ".build/documentation/index.html" \
"latest/documentation/fireblademath/" \
"Redirecting to Latest Docs"
# 2. latest/ -> main/documentation/fireblademath/
create_redirect ".build/documentation/latest/index.html" \
"../main/documentation/fireblademath/" \
"Redirecting to Main Docs"
# 3. latest/documentation/fireblademath/ -> main/documentation/fireblademath/
create_redirect ".build/documentation/latest/documentation/fireblademath/index.html" \
"../../../main/documentation/fireblademath/" \
"Redirecting to Main Docs"
# 4. documentation/fireblademath/ -> main/documentation/fireblademath/
create_redirect ".build/documentation/documentation/fireblademath/index.html" \
"../../main/documentation/fireblademath/" \
"Redirecting to Main Docs"
- name: Check Documentation Quality
run: |
make docs-check-coverage
make docs-check-links
- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: .build/documentation
deploy:
name: Deploy to GitHub Pages
needs: build-docs
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
smoke-test:
name: Post-Deployment Smoke Test
needs: deploy
runs-on: ubuntu-latest
steps:
- name: Check Documentation URL
run: |
# Wait a few seconds for CDN propagation
sleep 10
# Verify the versioned documentation path exists
curl --fail -sL https://fireblade-engine.github.io/math/main/documentation/fireblademath/ | grep -q "Documentation"
echo "Documentation is live at /math/main/"
- name: Check Root Redirect
run: |
# Verify that the root URL redirects correctly
RESPONSE=$(curl -sI https://fireblade-engine.github.io/math/ | head -n 1)
# Note: GitHub Pages might return 200 with the redirect meta tag, or a 301/302 if configured at the DNS level.
# Since we use a meta/JS redirect, we check for a 200 OK and then the content.
curl -s https://fireblade-engine.github.io/math/ | grep -q "Redirecting to Latest Docs"
echo "Root redirect is live at /math/ and points to latest docs"