feat: Add guide for publishing Quarto projects to GitHub Pages #158
Workflow file for this run
This file contains 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: Quarto Render | |
on: | |
workflow_dispatch: | |
pull_request: | |
schedule: | |
- cron: 00 12 1 * * | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event_name }} | |
cancel-in-progress: true | |
jobs: | |
quarto-render: | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- if: ${{ github.event_name == 'pull_request' }} | |
uses: r-lib/actions/pr-fetch@v2 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- uses: r-lib/actions/setup-r@v2 | |
- uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
packages: | |
any::knitr | |
any::rmarkdown | |
any::downlit | |
any::xml2 | |
any::webshot2 | |
- name: Set up Quarto | |
uses: quarto-dev/quarto-actions/setup@v2 | |
with: | |
version: pre-release | |
- name: Render Quarto Project | |
shell: bash | |
run: | | |
[ ! -f _quarto.yml ] && echo -e "project:\n output-dir: _site" > _quarto.yml | |
if grep -q "output-dir: _site" _quarto.yml; then | |
quarto render | |
else | |
quarto render --output-dir _site | |
fi | |
- name: Commit to Pull Request | |
shell: bash | |
run: | | |
git config --local user.name github-actions[bot] | |
git config --local user.email 41898282+github-actions[bot]@users.noreply.github.com | |
git add _site/* | |
git add _freeze/* | |
git commit -m 'ci: quarto automatic render' | |
skip-checks: true' || echo "No changes to commit" | |
- name: Create Pull Request | |
if: ${{ github.event_name != 'pull_request' }} | |
env: | |
BRANCH: ci/latest-quarto-updates | |
GH_TOKEN: ${{ secrets.github_token }} | |
shell: bash | |
run: | | |
if git show-ref --quiet refs/heads/${{ env.BRANCH }}; then | |
echo "Branch ${{ env.BRANCH }} already exists." | |
git checkout "${{ env.BRANCH }}" | |
else | |
echo "Branch ${{ env.BRANCH }} does not exist. Creating..." | |
git checkout -b "${{ env.BRANCH }}" | |
fi | |
git push --force origin ${{ env.BRANCH }} | |
gh pr create \ | |
--title "ci: quarto automatic render" \ | |
--body "GitHub Actions: ${{ github.workflow }} (${{ github.workflow_sha }})" \ | |
--base "main" \ | |
--label "Type: CI/CD :robot:" \ | |
--head "${{ env.BRANCH }}" \ | |
--repo ${{ github.repository }} \ | |
--assignee "${{ github.actor }}" \ | |
--reviewer "${{ github.actor }}" | |
gh pr merge --auto --squash --delete-branch | |
- name: Push to Pull Request | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: r-lib/actions/pr-push@v2 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} |