Skip to content

Commit f6ddd12

Browse files
committed
Previews
1 parent 7e19b2a commit f6ddd12

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

.github/workflows/docs.yml

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,26 @@ on:
55
branches:
66
- main
77
pull_request:
8+
types:
9+
- opened
10+
- reopened
11+
- synchronize
12+
- closed
813
branches:
914
- main
1015

1116
permissions:
12-
contents: read
13-
pages: write
14-
id-token: write
17+
contents: write # needed for pr-preview-action to commit to gh-pages
1518
pull-requests: write
19+
pages: write # for the official pages deployment
20+
id-token: write # for the official pages deployment
1621

1722
concurrency:
1823
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1924
cancel-in-progress: true
2025

2126
jobs:
22-
build:
27+
build-and-deploy:
2328
runs-on: ubuntu-latest
2429
steps:
2530
- uses: actions/checkout@v4
@@ -39,37 +44,24 @@ jobs:
3944
- name: Build site
4045
run: uv run mkdocs build
4146

47+
# For main branch pushes, use official GitHub Pages deployment
4248
- name: Upload Pages artifact
49+
if: github.ref == 'refs/heads/main'
4350
uses: actions/upload-pages-artifact@v3
4451
with:
4552
path: site
46-
name: github-pages
47-
48-
publish:
49-
needs: build
50-
runs-on: ubuntu-latest
51-
environment:
52-
name: ${{ github.event_name == 'pull_request' && format('preview-pr-{0}', github.event.pull_request.number) || 'github-pages' }}
53-
url: ${{ steps.deployment.outputs.page_url }}
54-
steps:
55-
- name: Setup Pages
56-
uses: actions/configure-pages@v4
5753

5854
- name: Deploy to GitHub Pages
59-
id: deployment
55+
if: github.ref == 'refs/heads/main'
6056
uses: actions/deploy-pages@v4
6157
with:
62-
preview: ${{ github.event_name == 'pull_request' }}
58+
artifact_name: github-pages
6359

64-
- name: Comment PR
60+
# For PRs, deploy preview using pr-preview-action
61+
- name: Deploy PR Preview
6562
if: github.event_name == 'pull_request'
66-
uses: actions/github-script@v7
63+
uses: rossjrw/pr-preview-action@v1
6764
with:
68-
script: |
69-
const comment = `📚 Documentation preview for this PR is ready!\n\nYou can view it at: ${{ steps.deployment.outputs.page_url }}`;
70-
github.rest.issues.createComment({
71-
owner: context.repo.owner,
72-
repo: context.repo.repo,
73-
issue_number: context.issue.number,
74-
body: comment
75-
});
65+
source-dir: site
66+
preview-branch: main
67+
umbrella-dir: pr-preview

0 commit comments

Comments
 (0)