-
Notifications
You must be signed in to change notification settings - Fork 7
58 lines (49 loc) · 1.84 KB
/
preview.yml
File metadata and controls
58 lines (49 loc) · 1.84 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
name: Deploy PR Preview
on:
pull_request:
branches:
- main # Adjust if needed
jobs:
build-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1' # Adjust as needed
- name: Install Jekyll deps
run: |
gem install bundler
bundle install
- name: Build Jekyll site
run: |
bundle exec jekyll build --baseurl "/website-previews/pr-${{ github.event.pull_request.number }}" --destination _site
- name: Deploy to website-previews repo
uses: peaceiris/actions-gh-pages@v3
with:
external_repository: cersonsky-lab/website-previews
publish_dir: ./_site
publish_branch: gh-pages
destination_dir: pr-${{ github.event.pull_request.number }}
deploy_key: ${{ secrets.PREVIEW_DEPLOY_KEY }}
- name: Wait for GitHub Pages deployment to propagate
run: |
echo "Checking preview URL: https://cersonsky-lab.github.io/website-previews/pr-${{ github.event.pull_request.number }}/"
for i in {1..10}; do
http_status=$(curl -o /dev/null -s -w "%{http_code}\n" https://cersonsky-lab.github.io/website-previews/pr-${{ github.event.pull_request.number }}/)
if [ "$http_status" -eq 200 ]; then
echo "Preview is live!"
break
else
echo "Waiting... ($i)"
sleep 10
fi
done
- name: Comment on PR with preview link
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
🚀 Preview your site is ready:
https://cersonsky-lab.github.io/website-previews/pr-${{ github.event.pull_request.number }}