Exporting a Google Doc into a PDF in a Github Action

Basically just a wget call

ETA: this, of course, I then rolled into a bash script with way too nice of usage()* for a few-liner. [*bash convention for the help function]

It turns out that grabbing the current pdf export of my resume during zola build was even easier than cleaning the Google HTML. Once you’ve setup the Google API keys it’s basically one wget (which is already installed on their ubuntu runner) call.

- name: download pdf
  shell: bash
  run: "wget -O 'tmp.pdf' --user-agent='github.com/knzai' \
    'https://www.googleapis.com/drive/v2/files/$\
    /export?mimeType=application/pdf&key=$'"
- name: replace pdf with newer, if valid (over 30k)
  shell: bash
  run: |
    if [ $(du -k 'tmp.pdf' | cut -f1) -gt 30 ]; then
      mv tmp.pdf static/assets/Kenzi\ Connor\ Resume.pdf
    else
      exit 1
    fi

© 2024. No rights reserved.