diff --git a/.github/workflows/build_book.yml b/.github/workflows/build_book.yml deleted file mode 100644 index 7df7f861..00000000 --- a/.github/workflows/build_book.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Rebuild and deploy book to gh-pages branch -on: - push: - branches: - - production - paths: - - 'source/**' - - 'build_html.sh' - -jobs: - deploy-book: - runs-on: ubuntu-latest - permissions: - contents: write - packages: write - - steps: - - 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 production - uses: actions/checkout@v2 - with: - ref: 'production' - - - 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/actions-gh-pages@v3.8.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: source/_build/html - cname: python.datasciencebook.ca - force_orphan: true # this will clean up all previous PR previews / main branch preview - - # rebuild the dev version after the previous copy was cleaned out - - name: checkout main - uses: actions/checkout@v2 - with: - ref: 'main' - - - 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/actions-gh-pages@v3.8.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: source/_build/html - keep_files: true - destination_dir: dev - # force_orphan: true # once peaceiris updates to v4, change this to true and keep_files: true for the PR / main branch deploy previews diff --git a/.github/workflows/update_book.yml b/.github/workflows/update_book.yml new file mode 100644 index 00000000..c9ff635f --- /dev/null +++ b/.github/workflows/update_book.yml @@ -0,0 +1,41 @@ +name: Rebuild and deploy book to gh-pages branch +on: + push: + branches: + - production + paths: + - 'source/**' + - 'build_html.sh' + +jobs: + deploy-book: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + + steps: + - name: checkout gh-pages + uses: actions/checkout@v2 + with: + ref: 'gh-pages' + + - name: Copy contents of dev/ to home folder + run: | + yes | cp -rf dev ${{ runner.home }} + + # Push update website to dev/ and clean out old commits + - name: Update website to contents of dev, remove all old commits and subpages + uses: peaceiris/actions-gh-pages@v3.8.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: dev/ + force_orphan: true # this will clean up all previous PR previews / main branch preview + cname: datasciencebook.ca + + - name: copy dev/ website back in + run: | + yes | cp -rf ${{ runner.home }}/dev dev + + - name: push the result to gh-pages + uses: stefanzweifel/git-auto-commit-action@v5