diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml index bd4df36be03..f193a7d6e9d 100644 --- a/.github/workflows/book.yml +++ b/.github/workflows/book.yml @@ -6,13 +6,6 @@ on: - master - develop - tags: - - '*' - - pull_request: - - merge_group: - jobs: bookdown: runs-on: ubuntu-latest @@ -23,51 +16,52 @@ jobs: image: pecan/depends:R4.1 steps: - # checkout source code - - uses: actions/checkout@v3 - # install rmarkdown - - name: Install rmarkdown - run: | - Rscript -e 'install.packages(c("rmarkdown","bookdown"))' - # copy files - - name: copy extfiles - run: | - mkdir -p book_source/extfiles - cp -f documentation/tutorials/01_Demo_Basic_Run/extfiles/* book_source/extfiles - # compile PEcAn code - - name: build needed modules - run: | - R CMD INSTALL base/logger - R CMD INSTALL base/remote - R CMD INSTALL base/utils - # render book - - name: Render Book - run: | - cd book_source - Rscript -e 'options(bookdown.render.file_scope=FALSE); bookdown::render_book("index.Rmd", "bookdown::gitbook")' - # save artifact - - uses: actions/upload-artifact@v3 - with: - name: pecan-documentation - path: book_source/_book/ - # download documentation repo - - name: Checkout documentation repo - if: github.event_name != 'pull_request' - uses: actions/checkout@v3 - with: - repository: ${{ github.repository_owner }}/pecan-documentation - path: pecan-documentation - token: ${{ secrets.GH_PAT }} - # upload new documentation - - name: publish to github - if: github.event_name != 'pull_request' - run: | - git config --global user.email "pecanproj@gmail.com" - git config --global user.name "GitHub Documentation Robot" - export VERSION=${GITHUB_REF##*/} - cd pecan-documentation - mkdir -p $VERSION - rsync -a --delete ../book_source/_book/ ${VERSION}/ - git add --all * - git commit -m "Build book from pecan revision ${GITHUB_SHA}" || true - git push -q origin master + - name: Checkout source code + uses: actions/checkout@v3 + + - name: Install rmarkdown + run: | + Rscript -e 'install.packages(c("rmarkdown","bookdown"))' + + - name: Copy extfiles + run: | + mkdir -p book_source/extfiles + cp -f documentation/tutorials/01_Demo_Basic_Run/extfiles/* book_source/extfiles + + - name: Build needed modules + run: | + R CMD INSTALL base/logger + R CMD INSTALL base/remote + R CMD INSTALL base/utils + + - name: Render Book + run: | + cd book_source + Rscript -e 'options(bookdown.render.file_scope=FALSE); bookdown::render_book("index.Rmd", "bookdown::gitbook")' + + - name: Save artifact + uses: actions/upload-artifact@v3 + with: + name: pecan-documentation + path: book_source/_book/ + + - name: Checkout documentation repo + if: github.event_name == 'push' && github.ref_type == 'branch' + uses: actions/checkout@v3 + with: + repository: ${{ github.repository_owner }}/pecan-documentation + path: pecan-documentation + token: ${{ secrets.GH_PAT }} + + - name: Publish to GitHub + if: github.event_name == 'push' && github.ref_type == 'branch' + run: | + git config --global user.email "pecanproj@gmail.com" + git config --global user.name "GitHub Documentation Robot" + export VERSION=${GITHUB_REF##*/} + cd pecan-documentation + mkdir -p $VERSION + rsync -a --delete ../book_source/_book/ ${VERSION}/ + git add --all * + git commit -m "Build book from pecan revision ${GITHUB_SHA}" || true + git push -q origin master