ci: restructure latex workflow #29
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: LaTeX to PDF | |
on: [push, pull_request] | |
env: | |
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: | |
compile_latex: | |
runs-on: ubuntu-latest | |
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 | |
- name: Upload PDFs as artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pdfs | |
path: ${{ env.OUTPUT_DIR }} | |
prepare_output: | |
runs-on: ubuntu-latest | |
needs: compile_latex | |
steps: | |
- name: Download PDFs | |
uses: actions/download-artifact@v3 | |
with: | |
name: pdfs | |
- 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: Download PDFs | |
uses: actions/download-artifact@v3 | |
with: | |
name: pdfs | |
- 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: Download PDFs | |
uses: actions/download-artifact@v3 | |
with: | |
name: pdfs | |
- 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 | |