Skip to content

Commit 1e404a2

Browse files
Proper workflow
1 parent 1f072be commit 1e404a2

2 files changed

Lines changed: 48 additions & 66 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 9 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
name: Deploy Jekyll site to GitHub Pages
1+
name: Deploy to GitHub Pages
22

33
on:
44
push:
55
branches:
66
- main
7-
pull_request:
8-
types: [opened, synchronize, reopened]
97

108
permissions:
11-
contents: read
12-
pages: write
13-
id-token: write
14-
pull-requests: write
15-
16-
concurrency:
17-
group: "pages-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || 'main' }}"
18-
cancel-in-progress: true
9+
contents: write
1910

2011
jobs:
21-
build:
12+
deploy:
2213
runs-on: ubuntu-latest
2314
steps:
2415
- name: Checkout
@@ -30,63 +21,15 @@ jobs:
3021
ruby-version: '3.2'
3122
bundler-cache: true
3223

33-
- name: Setup Pages
34-
id: pages
35-
uses: actions/configure-pages@v4
36-
3724
- name: Build with Jekyll
38-
run: |
39-
if [ "${{ github.event_name }}" == "pull_request" ]; then
40-
# For PRs, build with baseurl pointing to PR-specific folder
41-
bundle exec jekyll build --baseurl "/pr-${{ github.event.pull_request.number }}"
42-
else
43-
# For main branch, build to root
44-
bundle exec jekyll build
45-
fi
25+
run: bundle exec jekyll build
4626
env:
4727
JEKYLL_ENV: production
4828

49-
- name: Upload artifact
50-
uses: actions/upload-pages-artifact@v3
51-
with:
52-
path: _site
53-
54-
# Deploy to main domain when merged into main
55-
deploy-main:
56-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
57-
environment:
58-
name: github-pages
59-
url: ${{ steps.deployment.outputs.page_url }}
60-
runs-on: ubuntu-latest
61-
needs: build
62-
steps:
6329
- name: Deploy to GitHub Pages
64-
id: deployment
65-
uses: actions/deploy-pages@v4
66-
67-
# Deploy to PR-specific folder on pull requests
68-
deploy-pr:
69-
if: github.event_name == 'pull_request'
70-
runs-on: ubuntu-latest
71-
needs: build
72-
permissions:
73-
contents: write
74-
pull-requests: write
75-
steps:
76-
- name: Download artifact
77-
uses: actions/download-artifact@v4
78-
with:
79-
name: github-pages
80-
path: ./artifact
81-
82-
- name: Extract artifact
83-
run: |
84-
mkdir -p preview
85-
tar -xvf ./artifact/artifact.tar -C preview
86-
87-
- name: Deploy PR Preview
88-
uses: rossjrw/pr-preview-action@v1
30+
uses: JamesIves/github-pages-deploy-action@v4
8931
with:
90-
source-dir: preview
91-
preview-branch: gh-pages
92-
umbrella-dir: pr-preview
32+
folder: _site
33+
branch: gh-pages
34+
clean-exclude: pr-preview
35+
force: false

.github/workflows/preview.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deploy PR previews
2+
3+
concurrency: preview-${{ github.ref }}
4+
5+
on:
6+
pull_request:
7+
types:
8+
- opened
9+
- reopened
10+
- synchronize
11+
- closed
12+
13+
jobs:
14+
deploy-preview:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Ruby
21+
uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: '3.2'
24+
bundler-cache: true
25+
if: github.event.action != 'closed'
26+
27+
- name: Build with Jekyll
28+
run: bundle exec jekyll build
29+
env:
30+
JEKYLL_ENV: production
31+
if: github.event.action != 'closed'
32+
33+
- name: Deploy PR Preview
34+
uses: rossjrw/pr-preview-action@v1
35+
with:
36+
source-dir: _site
37+
preview-branch: gh-pages
38+
umbrella-dir: pr-preview
39+
action: auto

0 commit comments

Comments
 (0)