Skip to content

Commit 78ca98f

Browse files
Merge pull request #8 from PhilipMathieu/claude/fix-pr-preview-deploy-01BHa8uuPpeKWwLCjzYZWwUk
refactor: Switch to actions-based GitHub Pages deployment
2 parents 4ffa579 + 9edfbe2 commit 78ca98f

File tree

2 files changed

+62
-34
lines changed

2 files changed

+62
-34
lines changed

.github/workflows/pages.yml

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,37 @@
11
name: Deploy to GitHub Pages
22

33
on:
4-
# Deploy main branch to production
54
push:
65
branches: ["main"]
7-
8-
# Deploy PR previews
9-
pull_request:
10-
branches: ["main"]
11-
types: [opened, synchronize, reopened, closed]
12-
13-
# Allow manual deployment
146
workflow_dispatch:
157

168
permissions:
17-
contents: write
18-
pull-requests: write
9+
contents: read
10+
pages: write
11+
id-token: write
1912

2013
concurrency:
21-
group: pages-${{ github.ref }}
14+
group: "pages"
2215
cancel-in-progress: false
2316

2417
jobs:
2518
deploy:
26-
# Skip on PR close events (handled by cleanup job)
27-
if: github.event.action != 'closed'
19+
environment:
20+
name: github-pages
21+
url: ${{ steps.deployment.outputs.page_url }}
2822
runs-on: ubuntu-latest
2923
steps:
3024
- name: Checkout
3125
uses: actions/checkout@v4
3226

33-
- name: Deploy to GitHub Pages
34-
uses: rossjrw/pr-preview-action@v1
35-
with:
36-
source-dir: ./docs
37-
preview-branch: gh-pages
38-
umbrella-dir: pr-previews
39-
action: auto
40-
41-
cleanup:
42-
# Only run when PR is closed
43-
if: github.event.action == 'closed'
44-
runs-on: ubuntu-latest
45-
steps:
46-
- name: Checkout
47-
uses: actions/checkout@v4
27+
- name: Setup Pages
28+
uses: actions/configure-pages@v4
4829

49-
- name: Remove PR Preview
50-
uses: rossjrw/pr-preview-action@v1
30+
- name: Upload artifact
31+
uses: actions/upload-pages-artifact@v3
5132
with:
52-
source-dir: ./docs
53-
preview-branch: gh-pages
54-
umbrella-dir: pr-previews
55-
action: remove
33+
path: './docs'
34+
35+
- name: Deploy to GitHub Pages
36+
id: deployment
37+
uses: actions/deploy-pages@v4

.github/workflows/pr-check.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: PR Preview Build
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Upload docs artifact
19+
uses: actions/upload-artifact@v4
20+
with:
21+
name: pr-preview-${{ github.event.pull_request.number }}
22+
path: './docs'
23+
retention-days: 7
24+
25+
- name: Comment PR
26+
uses: actions/github-script@v7
27+
with:
28+
script: |
29+
const prNumber = context.issue.number;
30+
const runId = context.runId;
31+
const comment = `## 📦 PR Preview Built
32+
33+
The site has been built and is available as a downloadable artifact in this workflow run.
34+
35+
**To preview locally:**
36+
1. Download the artifact from the [workflow run](https://github.com/${{ github.repository }}/actions/runs/${runId})
37+
2. Extract and open \`index.html\` in your browser
38+
39+
Or wait for this PR to be merged to see it live on GitHub Pages.`;
40+
41+
github.rest.issues.createComment({
42+
issue_number: prNumber,
43+
owner: context.repo.owner,
44+
repo: context.repo.repo,
45+
body: comment
46+
});

0 commit comments

Comments
 (0)