Skip to content

Commit eed432e

Browse files
add PR deploy previews, and cleanup using force_orphan when production builds
1 parent 29187d7 commit eed432e

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

.github/workflows/build_book.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ jobs:
3030
github_token: ${{ secrets.GITHUB_TOKEN }}
3131
publish_dir: source/_build/html
3232
cname: python.datasciencebook.ca
33-
keep_files: true
34-
# force_orphan: true # once peaceiris updates to v4, change this to true and keep_files: true for the PR / main branch deploy previews
33+
force_orphan: true # this will clean up all previous PR previews / main branch preview
3534

3635

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "Rebuild and deploy PR version of book to gh-pages branch in pull###/ folder"
2+
on:
3+
pull_request:
4+
types: [reopened, opened, synchronize]
5+
paths:
6+
- source/**
7+
jobs:
8+
deploy-book:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
packages: write
13+
14+
steps:
15+
- name: checkout
16+
uses: actions/checkout@v2
17+
with:
18+
fetch-depth: '0'
19+
ref: ${{ github.head_ref }}
20+
21+
- name: Build the book
22+
run: |
23+
./build_html.sh
24+
25+
# Push the book's HTML to github-pages
26+
- name: GitHub Pages action
27+
uses: peaceiris/[email protected]
28+
with:
29+
github_token: ${{ secrets.GITHUB_TOKEN }}
30+
publish_dir: source/_build/html
31+
keep_files: true
32+
destination_dir: pull${{ github.event.number }}
33+
# force_orphan: true # once peaceiris updates to v4, change this to true and keep_files: true for the PR / main branch deploy previews
34+
35+
36+

0 commit comments

Comments
 (0)