Skip to content

Commit 13736ae

Browse files
authored
Refactor workflow for Jekyll PR previews
Updated workflow to build Jekyll previews and deploy to GitHub Pages. Signed-off-by: John Mertic <[email protected]>
1 parent 23b0153 commit 13736ae

File tree

2 files changed

+66
-76
lines changed

2 files changed

+66
-76
lines changed

.github/workflows/preview.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Jekyll PR Previews
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
pages: write
9+
id-token: write
10+
pull-requests: write
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
pr_path: ${{ steps.setpath.outputs.pr_path }}
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
21+
22+
- name: Setup Ruby
23+
uses: ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71 # v1.268.0
24+
with:
25+
ruby-version: "3.2"
26+
bundler-cache: true
27+
28+
# Determine output folder: main → root, PR → /pr-<number>/
29+
- name: Determine output path
30+
id: setpath
31+
run: |
32+
echo "pr_path=pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
33+
34+
# Build Jekyll
35+
- name: Build Jekyll
36+
run: |
37+
DEST="./_site/${{ steps.setpath.outputs.pr_path }}"
38+
mkdir -p "$DEST"
39+
bundle exec jekyll build --destination "$DEST" --trace --baseurl "/pr-${{ github.event.pull_request.number }}/"
40+
41+
# Upload the artifact for deployment
42+
- name: Upload Pages Artifact
43+
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
44+
with:
45+
path: _site
46+
47+
deploy:
48+
runs-on: ubuntu-latest
49+
needs: build
50+
51+
# Deploy for both PRs and main
52+
steps:
53+
- name: Deploy to GitHub Pages
54+
id: deploy
55+
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
56+
57+
# Comment PR preview URL
58+
- name: Comment PR Preview URL
59+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
60+
with:
61+
issue-number: ${{ github.event.pull_request.number }}
62+
body: |
63+
🔍 **Unique Jekyll PR Preview Ready**
64+
65+
Preview URL:
66+
**https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ github.event.pull_request.number }}/**

.github/workflows/scorecards.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)