Refine deploy workflow and Quarto config #4
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: Deploy Courses to GitHub Pages | |
| on: | |
| push: | |
| branches: [main, master] | |
| paths-ignore: | |
| - '.github/**' | |
| pull_request: | |
| branches: [main, master] | |
| paths-ignore: | |
| - '.github/**' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| env: | |
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Quarto | |
| uses: quarto-dev/quarto-actions/setup@v2 | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tinytex: true | |
| - name: Setup R | |
| uses: r-lib/actions/setup-r@v2 | |
| with: | |
| use-public-rspm: true | |
| - name: Install R dependencies | |
| run: | | |
| install.packages(c( | |
| "rmarkdown", | |
| "knitr", | |
| "ggplot2", | |
| "dplyr", | |
| "tidyr", | |
| "readr", | |
| "DT", | |
| "reticulate" | |
| )) | |
| shell: Rscript {0} | |
| - name: Render root website | |
| run: | | |
| echo "Rendering root website..." | |
| quarto render | |
| - name: Render courses | |
| run: | | |
| for course in */; do | |
| course=${course%/} | |
| if [ -d "$course" ] && [ -f "$course/_quarto.yml" ]; then | |
| echo "Rendering course: $course" | |
| cd "$course" | |
| quarto render | |
| cd .. | |
| fi | |
| done | |
| - name: Organize build output | |
| run: | | |
| for course in */; do | |
| course=${course%/} | |
| if [ -d "$course/_site" ]; then | |
| echo "Copying $course to _site/" | |
| mkdir -p "_site/$course" | |
| cp -r "$course/_site"/* "_site/$course/" | |
| fi | |
| done | |
| echo "Build complete. Site structure:" | |
| ls -la _site/ | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./_site | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |