forked from geoserver/geoserver
-
Notifications
You must be signed in to change notification settings - Fork 1
133 lines (117 loc) · 4.25 KB
/
docs-deploy.yml
File metadata and controls
133 lines (117 loc) · 4.25 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
name: Documentation Deployment
on:
push:
branches: [main, 2.28.x, 3.0.x, 3.1.x, afrigis-new-screenshots]
paths:
- 'doc/**'
- 'mkdocs.yml'
- '.github/workflows/docs-deploy.yml'
pull_request:
branches: [main, 3.0.x, 2.28.x]
paths:
- 'doc/**'
- 'mkdocs.yml'
- '.github/workflows/docs-deploy.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
build-docs:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0 # Full history for mike
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.x'
cache: 'pip'
- name: Install MkDocs and mike
run: |
pip install mkdocs mkdocs-material mkdocs-macros-plugin \
mkdocs-with-pdf pymdown-extensions mike
- name: Configure Git for mike
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Determine version and aliases
id: version
run: |
BRANCH=${GITHUB_REF##refs/heads/}
if [ "$BRANCH" = "main" ]; then
echo "version=latest" >> $GITHUB_OUTPUT
echo "title=Latest" >> $GITHUB_OUTPUT
echo "aliases=main 3.0.x" >> $GITHUB_OUTPUT
echo "is_default=false" >> $GITHUB_OUTPUT
elif [ "$BRANCH" = "2.28.x" ]; then
echo "version=2.28.x" >> $GITHUB_OUTPUT
echo "title=2.28.x" >> $GITHUB_OUTPUT
echo "aliases=" >> $GITHUB_OUTPUT
echo "is_default=false" >> $GITHUB_OUTPUT
elif [ "$BRANCH" = "3.0.x" ]; then
echo "version=3.0.x" >> $GITHUB_OUTPUT
echo "title=3.0.x" >> $GITHUB_OUTPUT
echo "aliases=" >> $GITHUB_OUTPUT
echo "is_default=false" >> $GITHUB_OUTPUT
elif [ "$BRANCH" = "3.1.x" ]; then
echo "version=3.1.x" >> $GITHUB_OUTPUT
echo "title=3.1.x" >> $GITHUB_OUTPUT
echo "aliases=" >> $GITHUB_OUTPUT
echo "is_default=false" >> $GITHUB_OUTPUT
else
echo "version=$BRANCH" >> $GITHUB_OUTPUT
echo "title=$BRANCH" >> $GITHUB_OUTPUT
echo "aliases=" >> $GITHUB_OUTPUT
echo "is_default=false" >> $GITHUB_OUTPUT
fi
# Deploy unified documentation with mike (builds and deploys)
- name: Deploy unified documentation
if: github.event_name == 'push'
run: |
VERSION=${{ steps.version.outputs.version }}
ALIASES="${{ steps.version.outputs.aliases }}"
mike deploy $VERSION $ALIASES \
--title "${{ steps.version.outputs.title }}" \
--push \
--update-aliases --alias-type symlink
# Build only on pull_request (no deploy)
- name: Build documentation (PR validation)
if: github.event_name == 'pull_request'
run: mkdocs build 2>&1 | grep -vF "../../api?urls.primaryName="
# Set default version (stable only)
- name: Set default version
if: github.event_name == 'push' && steps.version.outputs.is_default == 'true'
run: |
mike set-default ${{ steps.version.outputs.version }} --push
# Deploy gh-pages content to GitHub Pages via Actions API.
# This eliminates the ~15 min delay from pages-build-deployment.
# Requires Pages source set to "GitHub Actions" in repo settings.
deploy-pages:
if: github.event_name == 'push'
needs: build-docs
runs-on: ubuntu-22.04
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout gh-pages branch content
uses: actions/checkout@v6
with:
ref: gh-pages
path: _gh-pages-content
- name: Setup GitHub Pages
uses: actions/configure-pages@v4
- name: Upload to GitHub Pages
uses: actions/upload-pages-artifact@v3
with:
path: _gh-pages-content
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4