added caching for docker image #10
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: "Build and release PDFs" | |
on: | |
push: | |
tags: | |
- '*' | |
pull_request: | |
branches: [ master, main ] | |
paths: | |
- "**/*.tex" | |
- "**/*.bib" | |
env: | |
BUILD_CONTAINER: ghcr.io/moderncv/debian-texlive-docker:main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: docker cache | |
uses: actions/cache@v4 | |
id: docker-cache | |
with: | |
path: "./.cache/docker" | |
key: "texlive-docker" | |
- name: save docker | |
if: steps.docker-cache.outputs.cache-hit != 'true' | |
run: | | |
docker pull $BUILD_CONTAINER | |
mkdir -p ./.cache/docker | |
docker save -o "./.cache/docker/texlive-docker.tar" $BUILD_CONTAINER | |
- name: load docker | |
if: steps.docker-cache.outputs.cache-hit == 'true' | |
run: | | |
docker load -i "./.cache/docker/texlive-docker.tar" | |
- name: Make resume build script # the forward slash after asterisk is important for ignoring regular files | |
run: | | |
cat << 'EOF' > resume_script.sh | |
for folder in $(ls -d resumes/*/ | grep -v "resumes/header"); do | |
cd $folder && ls | |
NAME=$(basename "$folder") | |
SUFFIX=$(echo '${{github.ref_name}}' | sed 's|/|-|g') | |
latexmk -pdf -jobname="$NAME-$SUFFIX" | |
cd - | |
done | |
EOF | |
- name: Make cover letter build script | |
run: | | |
cat << 'EOF' > cover_script.sh | |
for folder in $(ls -d cover-letters/*/ | grep -v "cover-letters/header"); do | |
cd $folder && ls | |
NAME=$(basename "$folder") | |
SUFFIX=$(echo '${{github.ref_name}}' | sed 's|/|-|g') | |
latexmk -pdf -jobname="cover-$NAME-$SUFFIX" | |
cd - | |
done | |
EOF | |
- name: check script outputs | |
run: | | |
cat resume_script.sh | |
cat cover_script.sh | |
- name: run docker container to build pdfs | |
run: | | |
docker run -v ./:/workdir ghcr.io/moderncv/debian-texlive-docker:main bash -c "cd workdir && bash ./resume_script.sh && bash ./cover_script.sh" | |
- name: Upload PDFs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docs | |
path: | | |
cover-letters/*/*.pdf | |
resumes/*/*.pdf | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref_name, 'v') && github.ref_type == 'tag' | |
steps: | |
- name: make an artifacts directory | |
run: mkdir artifacts | |
- name: Download all workflow run artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./artifacts | |
merge-multiple: true | |
- name: Show artifacts | |
run: ls -R . | |
- name: Create a release | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: > | |
gh release create --latest --repo ${{github.repository}} | |
"${{github.ref_name}}" ./artifacts/resumes/*/*.pdf ./artifacts/cover-letters/*/*.pdf | |