Building a CV/Blog Automatically

Susan Vanderplas

2024-03-07

Blogs in Quarto

Documentation

Here’s a summary of the key files created within the starter blog project:

File Description
_quarto.yml Quarto project file.
index.qmd Blog home page.
about.qmd Blog about page.
posts/ Directory containing posts
posts/_metadata.yml Shared options for posts
styles.css Custom CSS for website

From https://quarto.org/docs/websites/website-blog.html

Documentation

My dilemma

  • I’m too lazy/busy to actually maintain an active blog
  • Most of my writing effort goes into research papers
  • I still want an online presence that showcases my work
Gif of Ursula from The Little Mermaid, saying 'Life's full of tough choices, innit?

The Realization

The Realization

Auto-Building Quarto Files

Talk Functions

  • format functions - create markup for specific fields
    e.g. format_post_name, format_abstract, format_slides, format_keywords, format_event

  • yaml_kv for fixing up yaml entries properly

  • talk_to_params - create data frame with columns that map to key-value pairs

  • create_talk - creates whole qmd file from parameters

  • get_image_link - creates an image for the talk

talk_to_params()

Goal: Format all the components of the qmd posts, keeping results in a data frame

format_post_name(x)format_slides(x)format_event(df)nametitleauthordateabstractslidesurlimagekeywordseventformat_abstract(x)talk_to_params(df)format_keywords(x)

create_talk()

Goal: Create a qmd file from a single row of data

get_img_link(params, path)yaml_kv(key, value)create_talk(params, path)titleauthordateabstractslidesurlimagekeywordsevent

Paper Layout

Paper Layout

Paper Functions

  • yaml_kv for fixing up yaml entries properly

  • format functions - create markup for specific fields
    e.g. format_title, format_github, format_addendum, format_citation, `format_bibtex

  • pub_to_params - create data frame with columns that map to key-value pairs

  • create_paper - creates whole qmd file from parameters

pub_to_params()

Goal: Format all the components of the qmd post, keeping results in a data frame

Works similarly to talk_to_params() but:

  • handles dates from bibtex files (not always ymd format)
  • adds bibliographic citation and bibtex code to entry text

create_paper()

Goal: Create a qmd file from a single row of data

Github Actions

General Process

cv-data submodulesrvanderplas.github.ioCVcv-data submodulecv-databuild sitebuild document

In cv-data repository

name: 'Trigger update of CV and srvanderplas.github.io'

on:
  push:
    branches: main
      
jobs:
  trigger_workflow:
    runs-on: ubuntu-latest
    steps:
      - name: Echo workflow name
        shell: bash
        run: |
          echo "I am workflow of cv-data"
      - name: Trigger site repo build
        uses: convictional/trigger-workflow-and-wait@v1.6.1
        with: # Set up for each dependency
          owner: srvanderplas
          repo: srvanderplas.github.io
          github_token: ${{ secrets.GH_TOKEN }}
          workflow_file_name: publish.yml
          ref: main
          wait_interval: 100
          propagate_failure: false
          trigger_workflow: true
          wait_workflow: false

In repos using cv-data submodules:

The important part:

on:
  workflow_dispatch:
  push:
    branches: main

Everything else:

name: Quarto Publish

jobs:
  build-deploy:
    runs-on: ubuntu-latest

    permissions:
      contents: write

    steps:
      - name: Install libcurl on Linux
        if: runner.os == 'Linux'
        run: sudo apt-get update -y && sudo apt-get install -y libcurl4-openssl-dev

      - name: Set up Quarto
        uses: quarto-dev/quarto-actions/setup@v2
        with:
          tinytex: false

      - name: Quarto version
        run: |
          quarto --version

      - name: Check out repository
        uses: actions/checkout@v4
        with:
          submodules: recursive
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Install R
        uses: r-lib/actions/setup-r@v2
        with:
          use-public-rspm: true

      - name: Setup renv
        uses: r-lib/actions/setup-renv@v2
        with:
          cache-version: 1

      - name: Publish
        uses: quarto-dev/quarto-actions/publish@v2
        with:
          target: gh-pages
        env:
          GS_AUTH: ${{ secrets.GS_AUTH }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}