Skip to content

Commit b1b2a6d

Browse files
committed
ci(docs): πŸ‘· πŸ“šοΈ split lint + deploy into separate workflows
Reorganizes the two docs workflows along event-vs-purpose lines: - ci-docs.yml (πŸ“– Docs CI): pull_request + workflow_dispatch only. Runs lint, vitest, and a non-deploying build. No longer touches gh-pages. - docs-deploy.yml (πŸ“šοΈ Docs deploy, renamed and rewritten from deploy-version-docs.yml): handles both deploys. `push: main` runs deploy-main β†’ /; `release: published` runs deploy-version β†’ /v{minor}/. workflow_dispatch is also wired into deploy-main so main can be redeployed by hand after editing a GitHub release note (release notes are fetched at build time via Octokit; the manual trigger picks up the edit). Shared concurrency group serializes pushes.
1 parent 904e013 commit b1b2a6d

3 files changed

Lines changed: 162 additions & 173 deletions

File tree

β€Ž.github/workflows/ci-docs.ymlβ€Ž

Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
name: πŸ“– Docs CI
22

33
on:
4-
push:
5-
branches: [main]
6-
paths:
7-
- "docs/**"
84
pull_request:
95
paths:
106
- "docs/**"
@@ -40,80 +36,9 @@ jobs:
4036
working-directory: docs
4137
run: npm test
4238

43-
build-and-deploy:
44-
name: πŸ—οΈ Build and deploy
45-
needs: lint
46-
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.repository == 'StarCitizenTools/mediawiki-skins-Citizen'
47-
runs-on: ubuntu-latest
48-
permissions:
49-
contents: write
50-
concurrency:
51-
group: gh-pages-deploy
52-
cancel-in-progress: false
53-
steps:
54-
- name: Checkout
55-
uses: actions/checkout@v6
56-
with:
57-
fetch-depth: 0
58-
59-
- name: Setup Node
60-
uses: actions/setup-node@v6
61-
with:
62-
node-version: 24
63-
cache: npm
64-
cache-dependency-path: docs/package-lock.json
65-
66-
- name: Install dependencies
67-
working-directory: docs
68-
run: npm ci
69-
70-
- name: Build with VitePress
71-
working-directory: docs
72-
env:
73-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74-
BASE_URL: /mediawiki-skins-Citizen/
75-
DOCS_VERSION: main
76-
ALGOLIA_APP_ID: ${{ vars.ALGOLIA_APP_ID }}
77-
ALGOLIA_API_KEY: ${{ vars.ALGOLIA_API_KEY }}
78-
ALGOLIA_INDEX_NAME: ${{ vars.ALGOLIA_INDEX_NAME }}
79-
run: npm run docs:build
80-
81-
- name: Checkout existing gh-pages into worktree
82-
run: |
83-
git fetch origin gh-pages || true
84-
if git show-ref --verify --quiet refs/remotes/origin/gh-pages; then
85-
git worktree add gh-pages origin/gh-pages
86-
else
87-
mkdir gh-pages
88-
(cd gh-pages && git init -b gh-pages)
89-
fi
90-
91-
- name: Sync new build into gh-pages root
92-
run: |
93-
# Remove only root-level files from the previous main build,
94-
# leaving versioned subpaths (v*) and the .git directory intact.
95-
find gh-pages -mindepth 1 -maxdepth 1 \
96-
-not -name 'v*' \
97-
-not -name '.git' \
98-
-exec rm -rf {} +
99-
cp -R docs/.vitepress/dist/. gh-pages/
100-
101-
- name: Regenerate versions.json
102-
run: node .github/scripts/generate-versions-json.mjs gh-pages
103-
104-
- name: Deploy to gh-pages
105-
uses: peaceiris/actions-gh-pages@v4
106-
with:
107-
github_token: ${{ secrets.GITHUB_TOKEN }}
108-
publish_dir: gh-pages
109-
publish_branch: gh-pages
110-
keep_files: false
111-
commit_message: "docs: deploy main @ ${{ github.sha }}"
112-
113-
build-pr:
114-
name: πŸ—οΈ Build (PR)
39+
build:
40+
name: πŸ—οΈ Build
11541
needs: lint
116-
if: github.event_name == 'pull_request'
11742
runs-on: ubuntu-latest
11843
steps:
11944
- name: Checkout
@@ -130,7 +55,7 @@ jobs:
13055
working-directory: docs
13156
run: npm ci
13257

133-
- name: Build (no deploy)
58+
- name: Build
13459
working-directory: docs
13560
env:
13661
DOCS_VERSION: main

β€Ž.github/workflows/deploy-version-docs.ymlβ€Ž

Lines changed: 0 additions & 95 deletions
This file was deleted.
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: πŸ“š Docs deploy
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "docs/**"
8+
release:
9+
types: [published]
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: write
14+
15+
concurrency:
16+
group: gh-pages-deploy
17+
cancel-in-progress: false
18+
19+
jobs:
20+
deploy-main:
21+
name: πŸš€ Deploy main
22+
if: |
23+
github.repository == 'StarCitizenTools/mediawiki-skins-Citizen' &&
24+
(github.event_name == 'push' || github.event_name == 'workflow_dispatch')
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v6
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Setup Node
33+
uses: actions/setup-node@v6
34+
with:
35+
node-version: 24
36+
cache: npm
37+
cache-dependency-path: docs/package-lock.json
38+
39+
- name: Install dependencies
40+
working-directory: docs
41+
run: npm ci
42+
43+
- name: Build with VitePress
44+
working-directory: docs
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
BASE_URL: /mediawiki-skins-Citizen/
48+
DOCS_VERSION: main
49+
ALGOLIA_APP_ID: ${{ vars.ALGOLIA_APP_ID }}
50+
ALGOLIA_API_KEY: ${{ vars.ALGOLIA_API_KEY }}
51+
ALGOLIA_INDEX_NAME: ${{ vars.ALGOLIA_INDEX_NAME }}
52+
run: npm run docs:build
53+
54+
- name: Checkout existing gh-pages into worktree
55+
run: |
56+
git fetch origin gh-pages || true
57+
if git show-ref --verify --quiet refs/remotes/origin/gh-pages; then
58+
git worktree add gh-pages origin/gh-pages
59+
else
60+
mkdir gh-pages
61+
(cd gh-pages && git init -b gh-pages)
62+
fi
63+
64+
- name: Sync new build into gh-pages root
65+
run: |
66+
# Remove only root-level files from the previous main build,
67+
# leaving versioned subpaths (v*) and the .git directory intact.
68+
find gh-pages -mindepth 1 -maxdepth 1 \
69+
-not -name 'v*' \
70+
-not -name '.git' \
71+
-exec rm -rf {} +
72+
cp -R docs/.vitepress/dist/. gh-pages/
73+
74+
- name: Regenerate versions.json
75+
run: node .github/scripts/generate-versions-json.mjs gh-pages
76+
77+
- name: Deploy to gh-pages
78+
uses: peaceiris/actions-gh-pages@v4
79+
with:
80+
github_token: ${{ secrets.GITHUB_TOKEN }}
81+
publish_dir: gh-pages
82+
publish_branch: gh-pages
83+
keep_files: false
84+
commit_message: "docs: deploy main @ ${{ github.sha }}"
85+
86+
deploy-version:
87+
name: πŸš€ Deploy version
88+
if: github.event_name == 'release' && github.repository == 'StarCitizenTools/mediawiki-skins-Citizen'
89+
runs-on: ubuntu-latest
90+
steps:
91+
- name: Resolve tag
92+
id: tag
93+
run: |
94+
TAG="${{ github.event.release.tag_name }}"
95+
if [[ ! "$TAG" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
96+
echo "Tag '$TAG' is not vMAJOR.MINOR.PATCH" >&2
97+
exit 1
98+
fi
99+
MINOR="v${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
100+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
101+
echo "minor=$MINOR" >> "$GITHUB_OUTPUT"
102+
103+
- name: Checkout tag
104+
uses: actions/checkout@v6
105+
with:
106+
ref: ${{ steps.tag.outputs.tag }}
107+
fetch-depth: 0
108+
109+
- name: Checkout generator script from main
110+
run: |
111+
git fetch origin main
112+
git checkout origin/main -- .github/scripts/generate-versions-json.mjs
113+
114+
- name: Setup Node
115+
uses: actions/setup-node@v6
116+
with:
117+
node-version: 24
118+
cache: npm
119+
cache-dependency-path: docs/package-lock.json
120+
121+
- name: Install dependencies
122+
working-directory: docs
123+
run: npm ci
124+
125+
- name: Build
126+
working-directory: docs
127+
env:
128+
BASE_URL: /mediawiki-skins-Citizen/${{ steps.tag.outputs.minor }}/
129+
DOCS_VERSION: ${{ steps.tag.outputs.minor }}
130+
run: npm run docs:build
131+
132+
- name: Checkout existing gh-pages into worktree
133+
run: |
134+
git fetch origin gh-pages || true
135+
if git show-ref --verify --quiet refs/remotes/origin/gh-pages; then
136+
git worktree add gh-pages origin/gh-pages
137+
else
138+
mkdir gh-pages
139+
(cd gh-pages && git init -b gh-pages)
140+
fi
141+
142+
- name: Place build at /{minor}/
143+
run: |
144+
MINOR="${{ steps.tag.outputs.minor }}"
145+
rm -rf "gh-pages/$MINOR"
146+
mkdir -p "gh-pages/$MINOR"
147+
cp -R docs/.vitepress/dist/. "gh-pages/$MINOR/"
148+
149+
- name: Regenerate versions.json
150+
run: node .github/scripts/generate-versions-json.mjs gh-pages
151+
152+
- name: Deploy to gh-pages
153+
uses: peaceiris/actions-gh-pages@v4
154+
with:
155+
github_token: ${{ secrets.GITHUB_TOKEN }}
156+
publish_dir: gh-pages
157+
publish_branch: gh-pages
158+
keep_files: false
159+
commit_message: "docs: deploy ${{ steps.tag.outputs.tag }} to /${{ steps.tag.outputs.minor }}/"

0 commit comments

Comments
Β (0)