Skip to content

Commit

Permalink
ci: restructure latex workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
felixevers committed Aug 19, 2024
1 parent ee323bc commit 80fc77a
Showing 1 changed file with 73 additions and 52 deletions.
125 changes: 73 additions & 52 deletions .github/workflows/latex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,80 @@ name: LaTeX to PDF

on: [push, pull_request]

env:
INTER_FONT_URL: "https://github.com/rsms/inter/releases/download/v4.0/Inter-4.0.zip"
INTER_FONT_ZIP: "Inter.zip"
OUTPUT_DIR: "output"
LATEX_ROOT_FILES: |
agb_app_zum_doc_patient.tex
agb_mediquu_connect.tex
agb_app_zum_doc.tex
agb_mediquu_netzmanager.tex
agb_mediquu_chat.tex
jobs:
build:
install_fonts:
runs-on: ubuntu-latest
steps:
- name: Install Inter font
run: |
sudo apt-get update
sudo apt-get install -y unzip fontconfig wget
mkdir -p ~/.local/share/fonts
wget -qO $INTER_FONT_ZIP $INTER_FONT_URL
unzip -o $INTER_FONT_ZIP -d ~/.local/share/fonts
fc-cache -f -v
compile_latex:
runs-on: ubuntu-latest
needs: install_fonts
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Compile LaTeX documents
uses: xu-cheng/latex-action@v2
with:
root_file: ${{ env.LATEX_ROOT_FILES }}
extra_system_packages: "inkscape"
latexmk_shell_escape: true

prepare_output:
runs-on: ubuntu-latest
needs: compile_latex
steps:
- name: Create output directory and move PDFs
run: |
mkdir -p ${{ env.OUTPUT_DIR }}
mv ./*.pdf ${{ env.OUTPUT_DIR }}
echo ${{ github.sha }} > ${{ env.OUTPUT_DIR }}/version.txt
upload_to_cdn:
runs-on: ubuntu-latest
needs: prepare_output
steps:
- name: Upload to CDN
uses: ryand56/r2-upload-action@latest
with:
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
r2-bucket: ${{ secrets.R2_BUCKET }}
source-dir: ${{ env.OUTPUT_DIR }}
destination-dir: ${{ github.sha }}

release_on_cdn:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: prepare_output
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Inter font
run: |
sudo apt-get update
sudo apt-get install -y unzip fontconfig wget
mkdir -p ~/.local/share/fonts
wget -qO Inter.zip https://github.com/rsms/inter/releases/download/v3.19/Inter-3.19.zip
unzip -o Inter.zip -d ~/.local/share/fonts
fc-cache -f -v
- name: Compile LaTeX documents
uses: xu-cheng/latex-action@v2
with:
root_file: |
agb_app_zum_doc_patient.tex
agb_mediquu_connect.tex
agb_app_zum_doc.tex
agb_mediquu_netzmanager.tex
agb_mediquu_chat.tex
extra_system_packages: "inkscape"
latexmk_shell_escape: true

- name: Generate output directory
run: |
mkdir -p output
mv ./*.pdf output
echo ${{ github.sha }} > output/version.txt
- name: Upload to cdn
uses: ryand56/r2-upload-action@latest
with:
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
r2-bucket: ${{ secrets.R2_BUCKET }}
source-dir: output
destination-dir: ${{ github.sha }}

- name: Release on cdn (on main)
if: github.ref == 'refs/heads/main'
uses: ryand56/r2-upload-action@latest
with:
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
r2-bucket: ${{ secrets.R2_BUCKET }}
source-dir: output
destination-dir: main
keep-file-fresh: true
- name: Release on CDN
uses: ryand56/r2-upload-action@latest
with:
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
r2-bucket: ${{ secrets.R2_BUCKET }}
source-dir: ${{ env.OUTPUT_DIR }}
destination-dir: main
keep-file-fresh: true

0 comments on commit 80fc77a

Please sign in to comment.