diff --git a/.github/workflows/build_book.yml b/.github/workflows/build_book.yml deleted file mode 100644 index a1a872213..000000000 --- a/.github/workflows/build_book.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Rebuild and deploy book to gh-pages branch -on: - push: - branches: - - production - paths: - - 'index.Rmd' - - '_bookdown.yml' - - '_output.yml' - - 'source/*.Rmd' - - 'source/*.bib' - - 'source/*.css' - - 'data/**' - - 'img/**' - - '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: docs/ - force_orphan: true # this will clean up all previous PR previews / main branch preview - cname: datasciencebook.ca - - # 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: docs/ - keep_files: true - destination_dir: dev - diff --git a/.github/workflows/update_book.yml b/.github/workflows/update_book.yml new file mode 100644 index 000000000..c5a8de583 --- /dev/null +++ b/.github/workflows/update_book.yml @@ -0,0 +1,48 @@ +name: Rebuild and deploy book to gh-pages branch +on: + push: + branches: + - production + paths: + - 'index.Rmd' + - '_bookdown.yml' + - '_output.yml' + - 'source/*.Rmd' + - 'source/*.bib' + - 'source/*.css' + - 'data/**' + - 'img/**' + - '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