CI/CD #224
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
| # NOTE: | |
| # We render the site in GitHub Actions because some pages (e.g. instructors.qmd) | |
| # require R to dynamically load data from CSV files. | |
| # | |
| # Netlify does not provide an R environment, so we cannot use the Quarto Netlify plugin. | |
| # | |
| # Instead, CI installs R + Quarto, renders the site, and deploys the | |
| # pre-rendered HTML to Netlify for both PR previews and production. | |
| name: CI/CD | |
| on: | |
| pull_request: | |
| branches: [devel] | |
| push: | |
| branches: [devel] | |
| schedule: | |
| - cron: '0 1 * * 0' # every Sunday at 01:00 UTC | |
| jobs: | |
| # ----------------------------- | |
| # PR preview build + deploy | |
| # ----------------------------- | |
| build-preview: | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Quarto | |
| uses: quarto-dev/quarto-actions/setup@v2 | |
| - name: Set up R | |
| uses: r-lib/actions/setup-r@v2 | |
| with: | |
| use-public-rspm: true | |
| - name: Install R dependencies (cached) | |
| uses: r-lib/actions/setup-r-dependencies@v2 | |
| with: | |
| cache: true | |
| cache-dependency-path: | | |
| DESCRIPTION | |
| renv.lock | |
| - name: Render Quarto Project | |
| run: quarto render | |
| - name: Deploy Preview to Netlify | |
| run: | | |
| npx netlify-cli deploy \ | |
| --auth "$NETLIFY_AUTH_TOKEN" \ | |
| --site "$NETLIFY_SITE_ID" \ | |
| --dir docs \ | |
| --message "PR #${{ github.event.number }} - ${{ github.sha }}" \ | |
| --alias "pr-${{ github.event.number }}" | |
| env: | |
| NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
| NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
| # ----------------------------- | |
| # Production deploy | |
| # ----------------------------- | |
| deploy-prod: | |
| if: github.ref == 'refs/heads/devel' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Quarto | |
| uses: quarto-dev/quarto-actions/setup@v2 | |
| - name: Set up R | |
| uses: r-lib/actions/setup-r@v2 | |
| with: | |
| use-public-rspm: true | |
| - name: Install R dependencies (cached) | |
| uses: r-lib/actions/setup-r-dependencies@v2 | |
| with: | |
| cache: true | |
| cache-dependency-path: | | |
| DESCRIPTION | |
| renv.lock | |
| - name: Render Quarto Project | |
| run: quarto render | |
| - name: Add CNAME for GitHub Pages | |
| run: echo "training.bioconductor.org" > docs/CNAME | |
| - name: Publish to GitHub Pages (optional) | |
| uses: quarto-dev/quarto-actions/publish@v2 | |
| with: | |
| target: gh-pages | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Deploy Production to Netlify | |
| run: | | |
| npx netlify-cli deploy \ | |
| --auth "$NETLIFY_AUTH_TOKEN" \ | |
| --site "$NETLIFY_SITE_ID" \ | |
| --dir docs \ | |
| --prod \ | |
| --message "devel @ ${{ github.sha }}" | |
| env: | |
| NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
| NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |