-
Notifications
You must be signed in to change notification settings - Fork 35
66 lines (54 loc) · 1.94 KB
/
preview.yml
File metadata and controls
66 lines (54 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Jekyll PR Previews
on:
pull_request:
permissions:
contents: read
pages: write
id-token: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
outputs:
pr_path: ${{ steps.setpath.outputs.pr_path }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Ruby
uses: ruby/setup-ruby@97ecb7b512899eb71ab1bf2310a624c6f1589ac6 # v1.308.0
with:
ruby-version: "3.2"
bundler-cache: true
# Determine output folder: main → root, PR → /pr-<number>/
- name: Determine output path
id: setpath
run: |
echo "pr_path=pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
# Build Jekyll
- name: Build Jekyll
run: |
DEST="./_site/${{ steps.setpath.outputs.pr_path }}"
mkdir -p "$DEST"
bundle exec jekyll build --destination "$DEST" --trace --baseurl "/pr-${{ github.event.pull_request.number }}/"
# Upload the artifact for deployment
- name: Upload Pages Artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: _site
deploy:
runs-on: ubuntu-latest
needs: build
# Deploy for both PRs and main
steps:
- name: Deploy to GitHub Pages
id: deploy
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
# Comment PR preview URL
- name: Comment PR Preview URL
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
🔍 **Unique Jekyll PR Preview Ready**
Preview URL:
**https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ github.event.pull_request.number }}/**