Update build-site.yml #2
This file contains hidden or 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: Build and Deploy Website | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'rmd/**' | |
| - 'build-site.R' | |
| - '.github/workflows/build-site.yml' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'rmd/**' | |
| - 'build-site.R' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Setup R | |
| uses: r-lib/actions/setup-r@v2 | |
| with: | |
| r-version: '4.3.0' | |
| use-public-rspm: true | |
| - name: Cache apt packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: /var/cache/apt/archives | |
| key: ${{ runner.os }}-apt-${{ hashFiles('.github/workflows/build-site.yml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-apt- | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| libcurl4-openssl-dev \ | |
| libssl-dev \ | |
| libxml2-dev \ | |
| pandoc | |
| - name: Cache R packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ env.R_LIBS_USER }} | |
| key: ${{ runner.os }}-r-${{ hashFiles('**/DESCRIPTION') }}-${{ hashFiles('.github/workflows/build-site.yml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-r- | |
| - name: Install R packages | |
| run: | | |
| Rscript -e 'install.packages(c("rmarkdown", "kableExtra"), repos="https://cloud.r-project.org")' | |
| - name: Cache Pandoc | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pandoc | |
| key: ${{ runner.os }}-pandoc-${{ hashFiles('rmd/**') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pandoc- | |
| - name: Build site | |
| run: | | |
| Rscript build-site.R | |
| - name: Create .nojekyll file | |
| run: touch docs/.nojekyll | |
| - name: Commit and push if changes | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add docs/ | |
| git diff --quiet && git diff --staged --quiet || (git commit -m "Auto-build website [skip ci]" && git push) |