Skip to content

Updates report project part 1 chapter #8

Updates report project part 1 chapter

Updates report project part 1 chapter #8

name: Compile and build all latex documents
on:
# Triggers the workflow on push or pull request events but only for the default branch
push:
branches: [ "main", "master" ]
paths:
- 'report/**'
- '.github/workflows/**'
pull_request:
branches: [ "main", "master" ]
paths:
- 'report/**'
- '.github/workflows/**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Defines concurrent policies for the workflow, for example, if a commit is made while
# the workflow is running, should the current run be cancelled or should the new run be queued
# Docs: https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
FILE_NAME: "main"
LATEX_SOURCE_DIR: "report/src"
PDF_OUTPUT_DIR: "out"
PDFLATEX_ARGS: "-file-line-error -interaction=nonstopmode -synctex=1 -output-format=pdf"
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# The permissions that the GitHub token has
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# docs: https://github.com/EndBug/add-and-commit?tab=readme-ov-file#faqs
- if: ${{ github.event_name == 'pull_request'}}
name: PR checkout
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- if: ${{ github.event_name != 'pull_request'}}
name: Normal checkout
uses: actions/checkout@v4
- name: Install and Update MikTeX
run: |
echo "${HOME}/bin" >> $GITHUB_PATH
set -e
sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/miktex.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D6BC243565B2087BC3F897C9277A7293F59E4889
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/miktex.gpg] https://miktex.org/download/ubuntu jammy universe" | sudo tee /etc/apt/sources.list.d/miktex.list
sudo apt-get update -y -q
sudo apt-get install -qq -y --no-install-recommends miktex
miktexsetup --verbose finish
initexmf --verbose --set-config-value=[MPM]AutoInstall=1
miktex --verbose packages update-package-database
miktex --verbose packages update
miktex --verbose packages install cm-super amsfonts
miktex --verbose fontmaps configure
miktex --verbose fndb refresh
initexmf --verbose --update-fndb
initexmf --report > miktex-report.txt
# Compile the latex document
- name: Compile latex document with pdflatex once
run: |
cd ${{ env.LATEX_SOURCE_DIR }}
pdflatex ${{ env.PDFLATEX_ARGS }} ${{ env.FILE_NAME}}
continue-on-error: true
# Compile the latex document with bibtex
- name: Compile latex document with bibtex
run: |
cd ${{ env.LATEX_SOURCE_DIR }}
bibtex ${{ env.FILE_NAME}}
# Compile the latex document with pdflatex twice
- name: Compile latex document with pdflatex twice
run: |
cd ${{ env.LATEX_SOURCE_DIR }}
pdflatex ${{ env.PDFLATEX_ARGS }} ${{ env.FILE_NAME}}
continue-on-error: true
# Compile the latex document with pdflatex thrice
- name: Compile latex document with pdflatex thrice
run: |
cd ${{ env.LATEX_SOURCE_DIR }}
pdflatex ${{ env.PDFLATEX_ARGS }} ${{ env.FILE_NAME}}
continue-on-error: true
# Move pdf file to output directory
- name: Move pdf file to output directory
run: |
cd ${{ env.LATEX_SOURCE_DIR }}
ls -lsa
cd ..
mkdir -p ${{ env.PDF_OUTPUT_DIR }}
ls -lsa
cd ..
cd ${{ env.LATEX_SOURCE_DIR }}
mv ${{ env.FILE_NAME }}.pdf ../${{ env.PDF_OUTPUT_DIR }}
# Commit all changed files back to the repository
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
add: '*.pdf'
message: '🔄 ci(report): compiles and deploys latex document'
default_author: github_actions