Skip to content

Commit 150ec43

Browse files
add build of diff, reset ownership in pr deploy
1 parent d13fd80 commit 150ec43

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

.github/workflows/deploy_pr_preview.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ jobs:
3131
checkName: "Rebuild docker image"
3232
ref: ${{ github.event.pull_request.head.sha }}
3333
timeoutSeconds: 60000
34+
35+
- name: Get Actions user id
36+
id: get_uid
37+
run: |
38+
actions_user_id=`id -u $USER`
39+
echo $actions_user_id
40+
echo "uid=$actions_user_id" >> $GITHUB_OUTPUT
3441
3542
- name: Checkout the repo
3643
uses: actions/checkout@v2
@@ -42,6 +49,11 @@ jobs:
4249
run: |
4350
./build_html.sh
4451
52+
- name: Reset ownership of workspace after build
53+
uses: peter-murray/reset-workspace-ownership-action@v1
54+
with:
55+
user_id: ${{ steps.get_uid.outputs.uid }}
56+
4557
# Push the book's HTML to github-pages
4658
- name: GitHub Pages action
4759
uses: peaceiris/[email protected]
@@ -52,11 +64,34 @@ jobs:
5264
destination_dir: pull${{ github.event.number }}
5365
# force_orphan: true # once peaceiris updates to v4, change this to true and keep_files: true for the PR / main branch deploy previews
5466

67+
- name: Checkout the gh-pages branch
68+
uses: actions/checkout@v2
69+
with:
70+
fetch-depth: '0'
71+
ref: 'gh-pages'
72+
73+
- name: Run website diff
74+
run: |
75+
rustup update
76+
pip install --upgrade pip
77+
pip install website_diff
78+
website_diff --old dev --new pull${{ github.event.number }} --diff diff${{ github.event.number }}
79+
80+
- name: GitHub Pages action to push diff
81+
uses: peaceiris/[email protected]
82+
with:
83+
github_token: ${{ secrets.GITHUB_TOKEN }}
84+
publish_dir: diff${{ github.event.number }}
85+
keep_files: true
86+
destination_dir: diff${{ github.event.number }}
87+
# force_orphan: true # once peaceiris updates to v4, change this to true and keep_files: true for the PR / main branch deploy previews
88+
5589
- name: Post URLS to PR thread
5690
uses: mshick/[email protected]
5791
with:
5892
message: |
5993
Hello! I've built a preview of your PR so that you can compare it to the current `main` branch.
6094
* PR deploy preview available [here](https://datasciencebook.ca/pull${{ github.event.number }}/index.html)
95+
* PR diff with `main` available [here](https://datasciencebook.ca/diff${{ github.event.number }}/index.html)
6196
* Current `main` deploy preview available [here](https://datasciencebook.ca/dev/index.html)
6297
* Public production build available [here](https://datasciencebook.ca)

0 commit comments

Comments
 (0)