Minor edits before Fall 2024 #261
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Rebuild and deploy PR version of book to gh-pages branch in pull###/ folder" | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
paths: | |
- 'source/**' | |
- 'Dockerfile' | |
branches: | |
- 'main' | |
jobs: | |
deploy-pr-preview: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
pull-requests: write | |
steps: | |
- name: Wait for potential build environment update | |
uses: fountainhead/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
checkName: "Rebuild docker image" | |
ref: ${{ github.event.pull_request.head.sha }} | |
timeoutSeconds: 60000 | |
- name: Get Actions user id | |
id: get_uid | |
run: | | |
actions_user_id=`id -u $USER` | |
echo $actions_user_id | |
echo "uid=$actions_user_id" >> $GITHUB_OUTPUT | |
- name: Checkout the repo | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: '0' | |
ref: ${{ github.head_ref }} | |
- name: Build the book | |
run: | | |
./build_html.sh | |
- name: Reset ownership of workspace after build | |
uses: peter-murray/reset-workspace-ownership-action@v1 | |
with: | |
user_id: ${{ steps.get_uid.outputs.uid }} | |
# Push the book's HTML to github-pages | |
- name: GitHub Pages action | |
uses: peaceiris/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: source/_build/html | |
keep_files: true | |
destination_dir: pull${{ github.event.number }} | |
# force_orphan: true # once peaceiris updates to v4, change this to true and keep_files: true for the PR / main branch deploy previews | |
- name: Checkout the gh-pages branch | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: '0' | |
ref: 'gh-pages' | |
- name: Run website diff | |
run: | | |
rustup update | |
pip install --upgrade pip | |
pip install website_diff | |
rm -rf diff${{ github.event.number }} | |
website_diff --old dev --new pull${{ github.event.number }} --diff diff${{ github.event.number }} | |
- name: GitHub Pages action to push diff | |
uses: peaceiris/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: diff${{ github.event.number }} | |
keep_files: true | |
destination_dir: diff${{ github.event.number }} | |
# force_orphan: true # once peaceiris updates to v4, change this to true and keep_files: true for the PR / main branch deploy previews | |
- name: Post URLS to PR thread | |
uses: mshick/[email protected] | |
with: | |
message: | | |
Hello! I've built a preview of your PR so that you can compare it to the current `main` branch. | |
* PR deploy preview available [here](https://python.datasciencebook.ca/pull${{ github.event.number }}/index.html) | |
* PR diff with `main` available [here](https://python.datasciencebook.ca/diff${{ github.event.number }}/index.html) | |
* Current `main` deploy preview available [here](https://python.datasciencebook.ca/dev/index.html) | |
* Public production build available [here](https://python.datasciencebook.ca) |