Skip to content

Commit b00039b

Browse files
committed
chore: deploy the user guide to GitHub Pages
1 parent f163ad4 commit b00039b

1 file changed

Lines changed: 64 additions & 46 deletions

File tree

Lines changed: 64 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,101 @@
11
# When changes are pushed to the develop branch,
2-
# build the current version of the User Guide
3-
# with Sphinx and deploy it to the gh-pages branch.
4-
#
5-
# @todo Consolidate checkouts
2+
# build the develop and the next minor versions of the User Guide
3+
# with MkDocs and deploy them to GitHub Pages.
64
name: Deploy User Guide (latest)
75

86
on:
97
push:
108
branches:
119
- 'develop'
1210
paths:
13-
- 'user_guide_src/**'
11+
- 'docs/**'
12+
- 'mkdocs.yml'
13+
- 'admin/anchors.py'
14+
- 'admin/llms.py'
15+
- '.github/workflows/deploy-userguide-latest.yml'
16+
workflow_dispatch:
17+
18+
concurrency:
19+
group: pages
20+
cancel-in-progress: false
1421

1522
permissions:
1623
contents: read
1724

1825
jobs:
1926
build:
20-
name: Deploy to gh-pages
21-
permissions:
22-
# Allow push to branch gh-pages
23-
contents: write
27+
name: Build User Guide
2428
if: (github.repository == 'codeigniter4/CodeIgniter4')
2529
runs-on: ubuntu-24.04
2630
steps:
27-
- name: Checkout
31+
- name: Checkout develop
2832
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2933
with:
34+
path: develop
3035
persist-credentials: false
3136

32-
- name: Setup PHP
33-
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
37+
- name: Checkout next minor
38+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3439
with:
35-
php-version: '8.2'
36-
coverage: none
40+
ref: '4.8'
41+
path: next
42+
persist-credentials: false
3743

3844
- name: Setup Python
3945
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
4046
with:
4147
python-version: '3.12'
4248

43-
- name: Install Sphinx
49+
- name: Install MkDocs
4450
run: |
4551
python -m pip install --upgrade pip
46-
pip install -r user_guide_src/requirements.txt
52+
pip install -r develop/docs/requirements.txt
4753
48-
# Build the latest User Guide
49-
- name: Build Docs with Sphinx
50-
run: make html
51-
working-directory: user_guide_src
54+
- name: Setup Pages
55+
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
5256

53-
- name: Add "Edit this page" links
57+
- name: Build the sites
58+
env:
59+
NO_MKDOCS_2_WARNING: '1'
60+
BASE_URL: https://codeigniter4.github.io/CodeIgniter4
5461
run: |
55-
cd user_guide_src
56-
# Fix permissions
57-
sudo chown -R runner:docker build/html/
58-
php add-edit-this-page build/html/
62+
mkdir pages
63+
64+
for name in develop next; do
65+
if [ ! -f "${name}/mkdocs.yml" ]; then
66+
echo "::notice::The ${name} branch has no mkdocs.yml, so it is not deployed."
67+
continue
68+
fi
69+
70+
(
71+
cd "${name}"
72+
SITE_URL="${BASE_URL}/${name}/" mkdocs build --strict
73+
python admin/llms.py
74+
python admin/anchors.py
75+
)
76+
77+
mv "${name}/site" "pages/${name}"
78+
done
79+
80+
cp develop/docs/overrides/assets/versions.json pages/versions.json
81+
echo '<!doctype html><meta http-equiv="refresh" content="0; url=develop/">' > pages/index.html
5982
60-
# Create an artifact of the html output
6183
- name: Upload artifact
62-
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
84+
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
6385
with:
64-
name: HTML Documentation
65-
path: user_guide_src/build/html/
66-
67-
# Commit changes to the gh-pages branch
68-
- name: Commit changes
69-
run: |
70-
git clone https://github.com/codeigniter4/CodeIgniter4.git --branch gh-pages --single-branch gh-pages
71-
cp -r user_guide_src/build/html/* gh-pages/
72-
cd gh-pages
73-
git config --local user.email "action@github.com"
74-
git config --local user.name "${GITHUB_ACTOR}"
75-
git add .
76-
# Ignore failures due to lack of changes
77-
git commit -m "Update User Guide" -a || true
86+
path: pages
7887

79-
- name: Push changes
80-
working-directory: gh-pages
81-
env:
82-
PUSH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
83-
run: bash ${GITHUB_WORKSPACE}/.github/scripts/secure-git-push https://github.com/codeigniter4/CodeIgniter4.git HEAD:gh-pages
88+
deploy:
89+
name: Deploy to GitHub Pages
90+
needs: build
91+
runs-on: ubuntu-24.04
92+
permissions:
93+
pages: write
94+
id-token: write
95+
environment:
96+
name: github-pages
97+
url: ${{ steps.deployment.outputs.page_url }}
98+
steps:
99+
- name: Deploy
100+
id: deployment
101+
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1

0 commit comments

Comments
 (0)