-
Notifications
You must be signed in to change notification settings - Fork 1
136 lines (118 loc) · 4.45 KB
/
docs-github-pages-publish.yml
File metadata and controls
136 lines (118 loc) · 4.45 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
name: Docs GitHub Pages Publish
on:
push:
branches:
- main
- master
paths:
- "docs/**"
- "mkdocs.yml"
- "docs/requirements-mkdocs.txt"
- "scripts/run-mkdocs.js"
- "package.json"
- "package-lock.json"
- "README.md"
- ".github/workflows/docs-github-pages-publish.yml"
workflow_dispatch:
inputs:
git_ref:
description: "Branch, tag, or commit to publish from (rollback)"
required: false
type: string
site_url:
description: "MkDocs site_url override"
required: false
default: "https://jacobinwwey.github.io/NoteConnection/"
type: string
base_path:
description: "MkDocs base path override"
required: false
default: "/NoteConnection/"
type: string
permissions:
contents: write
concurrency:
group: docs-github-pages
cancel-in-progress: false
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
jobs:
verify-diataxis-map:
name: verify-diataxis-map
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.git_ref != '' && github.event.inputs.git_ref || github.ref }}
lfs: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Verify Diataxis mapping governance
run: npm run docs:diataxis:check
build-site:
name: build-site
runs-on: ubuntu-latest
needs: verify-diataxis-map
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.git_ref != '' && github.event.inputs.git_ref || github.ref }}
lfs: false
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: docs/requirements-mkdocs.txt
- name: Install MkDocs dependencies
run: pip install -r docs/requirements-mkdocs.txt
- name: Resolve MkDocs runtime URL config
shell: bash
run: |
SITE_URL="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.site_url || '' }}"
BASE_PATH="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.base_path || '' }}"
if [ -z "${SITE_URL}" ]; then
SITE_URL="https://jacobinwwey.github.io/NoteConnection/"
fi
if [ -z "${BASE_PATH}" ]; then
BASE_PATH="/NoteConnection/"
fi
echo "MKDOCS_SITE_URL=${SITE_URL}" >> "$GITHUB_ENV"
echo "MKDOCS_BASE_PATH=${BASE_PATH}" >> "$GITHUB_ENV"
echo "MKDOCS_DOCS_HOST=https://jacobinwwey.github.io/" >> "$GITHUB_ENV"
echo "site_url=${SITE_URL}" >> "$GITHUB_OUTPUT"
echo "base_path=${BASE_PATH}" >> "$GITHUB_OUTPUT"
- name: Build docs site
run: mkdocs build --config-file mkdocs.yml
- name: Preflight GitHub Pages enablement check
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
PAGES_API="https://api.github.com/repos/${{ github.repository }}/pages"
STATUS_CODE="$(curl -sS -o /tmp/pages-site.json -w '%{http_code}' \
-H 'Accept: application/vnd.github+json' \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${PAGES_API}")"
if [ "${STATUS_CODE}" = "404" ]; then
echo "::warning::GitHub Pages site is not enabled yet for this repository. CI can still publish gh-pages branch, but https://jacobinwwey.github.io/NoteConnection/ will stay 404 until Settings -> Pages is configured to Deploy from branch (gh-pages / root)."
elif [ "${STATUS_CODE}" -ge 200 ] && [ "${STATUS_CODE}" -lt 300 ]; then
echo "GitHub Pages site API is available (HTTP ${STATUS_CODE})."
else
echo "::warning::Unable to verify GitHub Pages site state (HTTP ${STATUS_CODE})."
fi
- name: Deploy docs to gh-pages branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: build/mkdocs-site
publish_branch: gh-pages
force_orphan: true
commit_message: "docs: publish site from ${{ github.sha }}"