Update README.md #110
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: Render paper with Nix and Quarto | |
on: | |
push: | |
branches: [main, master] | |
pull_request: | |
branches: [main, master] | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 0 | |
- name: Check if manuscript changed | |
id: check_changes | |
run: | | |
# Check if there is at least one commit | |
if git rev-list --count HEAD >/dev/null 2>&1 && [ "$(git rev-list --count HEAD)" -gt 1 ]; then | |
# Check against the previous commit | |
if git diff --name-only HEAD^ HEAD | grep -q "^_manuscript/L2_VWP_webcam_ET.qmd$"; then | |
echo "changed=true" >> $GITHUB_ENV | |
else | |
echo "changed=false" >> $GITHUB_ENV | |
fi | |
else | |
# Handle initial commit or shallow clone (always render) | |
echo "changed=true" >> $GITHUB_ENV | |
fi | |
- name: Install Nix | |
if: env.changed == 'true' | |
uses: DeterminateSystems/nix-installer-action@main | |
with: | |
logger: pretty | |
log-directives: nix_installer=trace | |
backtrace: full | |
- name: Use rstats-on-nix cache | |
if: env.changed == 'true' | |
uses: cachix/cachix-action@v15 | |
with: | |
name: rstats-on-nix | |
- name: Generate default.nix | |
if: env.changed == 'true' | |
run: nix-shell -p R rPackages.rix --run "R -e 'source(\"create_dev_env.R\")'" | |
- name: Install MS fonts | |
if: env.changed == 'true' | |
run: | | |
echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | sudo debconf-set-selections | |
sudo apt-get install -y --no-install-recommends fontconfig ttf-mscorefonts-installer | |
fc-cache -fv | |
- name: Build development environment | |
if: env.changed == 'true' | |
run: | | |
nix-build | |
- name: Quarto Render paper | |
if: env.changed == 'true' | |
run: | | |
nix-shell --run "quarto render _manuscript/L2_VWP_webcam_ET.qmd" | |
- name: Upload rendered paper | |
if: env.changed == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.name "GitHub Actions Bot" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "Rendered manuscript" | |
git push origin main | |