Skip to content

Commit dd8d799

Browse files
committed
commit to main for docs deploy action
1 parent 01a4468 commit dd8d799

2 files changed

Lines changed: 30 additions & 65 deletions

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release
33
on:
44
push:
55
tags:
6-
- 'v*.*.*' # Trigger on version tags like v1.0.0, v2.1.3, etc.
6+
- "v*.*.*" # Trigger on version tags like v1.0.0, v2.1.3, etc.
77

88
jobs:
99
build:
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v4
1414
with:
15-
fetch-depth: 0 # Fetch all history for proper versioning
15+
fetch-depth: 0 # Fetch all history for proper versioning
1616

1717
- name: Set up uv
1818
uses: astral-sh/setup-uv@v4
@@ -38,14 +38,14 @@ jobs:
3838

3939
publish-to-pypi:
4040
name: Publish to PyPI
41-
if: startsWith(github.ref, 'refs/tags/') # Only publish on tags
41+
if: startsWith(github.ref, 'refs/tags/') # Only publish on tags
4242
needs: build
4343
runs-on: ubuntu-latest
4444
environment:
4545
name: pypi
4646
url: https://pypi.org/p/nexusLIMS
4747
permissions:
48-
id-token: write # Required for trusted publishing
48+
id-token: write # Required for trusted publishing
4949

5050
steps:
5151
- name: Download distribution packages
@@ -62,7 +62,7 @@ jobs:
6262
needs: publish-to-pypi
6363
runs-on: ubuntu-latest
6464
permissions:
65-
contents: write # Required to create releases
65+
contents: write # Required to create releases
6666

6767
steps:
6868
- uses: actions/checkout@v4
@@ -147,28 +147,24 @@ jobs:
147147
mkdir -p "$VERSION_DIR/_static"
148148
cp docs/_static/switcher.json "$VERSION_DIR/_static/switcher.json"
149149
150-
# Update stable to point to this version
150+
# Update stable redirect to point to this version
151151
rm -rf stable
152-
cp -r "$VERSION_DIR" stable
153-
154-
# Update latest redirect
155-
rm -rf latest
156-
mkdir -p latest
157-
cat > latest/index.html << 'EOF'
152+
mkdir -p stable
153+
cat > stable/index.html << EOF
158154
<!DOCTYPE html>
159155
<html>
160156
<head>
161-
<meta http-equiv="refresh" content="0; url=../stable/">
162-
<link rel="canonical" href="../stable/" />
163-
<title>Redirecting to stable documentation</title>
157+
<meta http-equiv="refresh" content="0; url=../$VERSION_DIR/">
158+
<link rel="canonical" href="../$VERSION_DIR/" />
159+
<title>Redirecting to stable documentation ($VERSION_DIR)</title>
164160
</head>
165161
<body>
166-
<p>Redirecting to <a href="../stable/">stable documentation</a>...</p>
162+
<p>Redirecting to <a href="../$VERSION_DIR/">stable documentation ($VERSION_DIR)</a>...</p>
167163
</body>
168164
</html>
169165
EOF
170166
171-
git add "$VERSION_DIR" stable latest docs/_static/switcher.json
167+
git add "$VERSION_DIR" stable docs/_static/switcher.json
172168
git commit -m "Deploy docs for version ${{ steps.version.outputs.version }}" || echo "No changes to commit"
173169
git push origin gh-pages
174170

.github/workflows/test.yml

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ jobs:
7373
needs: test
7474
runs-on: ubuntu-latest
7575
permissions:
76-
pages: write # Required to deploy to GitHub Pages
77-
id-token: write # Required for OIDC authentication
76+
contents: write # Required to push to gh-pages branch
7877
steps:
7978
- uses: actions/checkout@v4
8079

@@ -106,62 +105,32 @@ jobs:
106105
# Create version switcher for PyData Sphinx Theme navigation
107106
run: python scripts/generate_switcher_json.py
108107

109-
- name: Prepare Pages artifact
110-
# Assemble final site structure with docs and coverage in _site directory
111-
run: |
112-
mkdir -p _site
113-
rsync -avr _build/ _site/
114-
mkdir -p _site/_static
115-
cp docs/_static/switcher.json _site/_static/switcher.json
116-
mkdir -p _site/coverage
117-
if [ -d "tests/coverage" ]; then
118-
rsync -avr tests/coverage/ _site/coverage/
119-
fi
120-
121-
- name: Setup Pages
122-
# Configure GitHub Pages deployment settings
123-
id: pages
124-
uses: actions/configure-pages@v5
125-
126-
- name: Upload artifact
127-
# Upload the complete site as a Pages deployment artifact
128-
uses: actions/upload-pages-artifact@v3
129-
with:
130-
path: _site
131-
132-
- name: Deploy to GitHub Pages
133-
# Deploy the uploaded artifact to GitHub Pages
134-
id: deployment
135-
uses: actions/deploy-pages@v4
136-
137-
- name: Create latest redirect
138-
# Create a /latest/ redirect in gh-pages branch pointing to /stable/
108+
- name: Deploy to gh-pages branch
109+
# Deploy docs to gh-pages branch in stable/ directory
139110
run: |
140111
git config user.name "github-actions[bot]"
141112
git config user.email "github-actions[bot]@users.noreply.github.com"
142113
git fetch origin gh-pages
143114
git checkout gh-pages
144115
git pull origin gh-pages
116+
117+
# Deploy to latest directory (main branch = latest)
145118
rm -rf latest
146119
mkdir -p latest
147-
cat > latest/index.html << 'EOF'
148-
<!DOCTYPE html>
149-
<html>
150-
<head>
151-
<meta http-equiv="refresh" content="0; url=../stable/">
152-
<link rel="canonical" href="../stable/" />
153-
<title>Redirecting to stable documentation</title>
154-
</head>
155-
<body>
156-
<p>Redirecting to <a href="../stable/">stable documentation</a>...</p>
157-
</body>
158-
</html>
159-
EOF
120+
rsync -avr _build/ latest/
121+
122+
# Add coverage if available
123+
if [ -d "tests/coverage" ]; then
124+
mkdir -p latest/coverage
125+
rsync -avr tests/coverage/ latest/coverage/
126+
fi
127+
128+
# Commit and push
160129
git add latest
161-
git commit -m "Update latest redirect to stable" || echo "No changes to commit"
130+
git commit -m "Deploy docs to latest from main branch" || echo "No changes to commit"
162131
git push origin gh-pages
163-
echo "✅ Latest redirect updated!"
164-
echo "🔗 https://datasophos.github.io/NexusLIMS/latest/ → stable"
132+
echo "✅ Documentation deployed to latest!"
133+
echo "🔗 https://datasophos.github.io/NexusLIMS/latest/"
165134
166135
deploy-pr-docs:
167136
# Deploy documentation preview for pull requests to gh-pages branch

0 commit comments

Comments
 (0)