diff --git a/.github/workflows/build-book.yaml b/.github/workflows/build-book.yaml new file mode 100644 index 00000000..98b4d804 --- /dev/null +++ b/.github/workflows/build-book.yaml @@ -0,0 +1,57 @@ +on: + push: + branches: '*' + schedule: + # run every day at 11 PM + - cron: '0 23 * * *' + +jobs: + build: + runs-on: macOS-latest + steps: + - name: Checkout repo + uses: actions/checkout@master + + - name: Setup R + uses: r-lib/actions/setup-r@master + + - name: Install pandoc and pandoc citeproc + run: | + brew install pandoc + brew install pandoc-citeproc + + - name: Cache R packages + uses: actions/cache@v1 + with: + path: ${{ env.R_LIBS_USER }} + key: r-${{ hashFiles('DESCRIPTION') }} + restore-keys: r- + + - name: Cache bookdown results + uses: actions/cache@v1 + with: + path: _bookdown_files + key: bookdown-${{ hashFiles('**/*Rmd') }} + restore-keys: bookdown- + + - name: Install packages + run: | + R -e 'install.packages("remotes")' + R -e 'remotes::install_deps(dependencies = TRUE)' + + - name: Install PhantomJS + run: R -e 'webshot::install_phantomjs()' + + - name: Build site + run: Rscript -e 'bookdown::render_book("index.Rmd", quiet = TRUE)' + + - name: Install npm + uses: actions/setup-node@v1 + + - name: Deploy to Netlify + # NETLIFY_AUTH_TOKEN added in the repo's secrets + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + run: | + npm install netlify-cli -g + netlify deploy --prod --dir _book