Skip to content

Commit 9a6f8db

Browse files
chore: Simplify docs GitHub Pages deployment (#720)
1 parent 9e8d63b commit 9a6f8db

2 files changed

Lines changed: 18 additions & 15 deletions

File tree

.github/workflows/docs.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
1-
name: Docs
1+
# Documentation Deployment Pipeline
2+
#
3+
# - PR with docs changes: build a /-rooted bundle
4+
# - push to main with docs changes: build /Apollon/-rooted bundle and deploy
5+
# it to GitHub Pages
26

3-
# - PR with docs changes: build a /-rooted bundle (preview)
4-
# - push to main with docs changes: build /Apollon/-rooted bundle, deploy
5-
# to GitHub Pages
7+
name: Docs
68

79
on:
810
push:
911
branches: [main]
1012
paths:
1113
- "docs/**"
1214
- "library/**"
15+
- "package.json"
1316
- "pnpm-lock.yaml"
1417
- "pnpm-workspace.yaml"
18+
- ".nvmrc"
1519
- ".github/workflows/docs.yml"
1620
pull_request:
21+
types: [opened, synchronize, reopened]
1722
paths:
1823
- "docs/**"
1924
- "library/**"
25+
- "package.json"
26+
- "pnpm-lock.yaml"
27+
- "pnpm-workspace.yaml"
28+
- ".nvmrc"
2029
- ".github/workflows/docs.yml"
2130
workflow_dispatch:
2231

2332
permissions:
2433
contents: read
25-
pages: write
26-
id-token: write
2734

2835
concurrency:
2936
group: docs-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || github.ref }}
@@ -48,7 +55,7 @@ jobs:
4855

4956
- id: flag
5057
run: |
51-
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
58+
if [[ "${{ github.ref }}" == "refs/heads/main" && "${{ github.event_name }}" != "pull_request" ]]; then
5259
echo "is-production=true" >> "$GITHUB_OUTPUT"
5360
else
5461
echo "is-production=false" >> "$GITHUB_OUTPUT"
@@ -74,13 +81,6 @@ jobs:
7481
env:
7582
DOCUSAURUS_BASE_URL: ${{ steps.flag.outputs.is-production == 'true' && '/Apollon/' || '/' }}
7683

77-
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
78-
with:
79-
name: docs-build
80-
path: docs/build
81-
retention-days: 7
82-
if-no-files-found: error
83-
8484
- if: steps.flag.outputs.is-production == 'true'
8585
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
8686
with:
@@ -91,6 +91,9 @@ jobs:
9191
needs: build
9292
if: needs.build.outputs.is-production == 'true'
9393
runs-on: ubuntu-latest
94+
permissions:
95+
pages: write
96+
id-token: write
9497
environment:
9598
name: github-pages
9699
url: ${{ steps.deployment.outputs.page_url }}

docs/docusaurus.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const config: Config = {
3838
},
3939

4040
url: "https://ls1intum.github.io",
41-
// Surge preview ('/') vs GitHub Pages production ('/Apollon/').
41+
// Pull request builds use '/', GitHub Pages production uses '/Apollon/'.
4242
baseUrl: process.env.DOCUSAURUS_BASE_URL || "/Apollon/",
4343
organizationName: "ls1intum",
4444
projectName: "Apollon",

0 commit comments

Comments
 (0)