Skip to content

Update main.yml

Update main.yml #31

Workflow file for this run

name: Render and Deploy All Quarto Documents
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
render:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Git user
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Check if docs branch exists
id: check_docs_branch
run: |
if git show-ref --verify --quiet refs/heads/docs; then
echo "Branch docs exists"
echo "branch-exists=true" >> $GITHUB_ENV
else
echo "Branch docs does not exist"
echo "branch-exists=false" >> $GITHUB_ENV
fi
- name: Create docs branch if it does not exist
if: env.branch-exists == 'false'
run: |
git checkout -b docs
git push https://x-access-token:${{ secrets.MY_GITHUB_PAT }}@github.com/tensorchiefs/data.git docs
- name: Checkout docs branch if it exists
if: env.branch-exists == 'true'
run: |
git checkout docs
- name: Set up R
uses: r-lib/actions/setup-r@v2
- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
- name: Install specific R packages
run: |
Rscript -e 'install.packages(c("rmarkdown", "ggplot2", "remotes"))'
Rscript -e 'remotes::install_github("tensorchiefs/data", subdir = "R/edudat", dependencies = TRUE, upgrade = "always", verbose = TRUE)'
- name: Render QMD files
run: |
quarto render data/*.qmd --to gfm
- name: Commit and push rendered files to docs branch
run: |
git add .
git commit -m 'Update rendered documentation' || echo "No changes to commit"
git push https://x-access-token:${{ secrets.MY_GITHUB_PAT }}@github.com/tensorchiefs/data.git docs
env:
GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }}
# Optional deployment step, commented out for now
# - name: Deploy to GitHub Pages
# uses: peaceiris/actions-gh-pages@v3
# with:
# personal_token: ${{ secrets.MY_GITHUB_PAT }}
# publish_dir: ./data
# publish_branch: gh-docs