Skip to content

Instantly share code, notes, and snippets.

@bozzelliandrea
Created September 26, 2022 16:16
Show Gist options
  • Save bozzelliandrea/7e236cbba64fa6b507ad3993f33a49f9 to your computer and use it in GitHub Desktop.
Save bozzelliandrea/7e236cbba64fa6b507ad3993f33a49f9 to your computer and use it in GitHub Desktop.
Github Action - LaTex Compiler to PDF
name: LaTex Compiler to PDF
on:
push:
branches: [ main ]
paths: 'docs/**'
workflow_dispatch:
env:
FILE_PATH: docs/
FILE_NAME: resume
RESULT_NAME: converted_resume
jobs:
build_latex:
runs-on: ubuntu-latest
steps:
- name: Get current date
id: date
run: |
current_date=$(date +'%Y-%m-%d %H:%M:%S')
echo "current execution date $current_date"
echo "::set-output name=date::$(date '+%Y%m%d%H%M%S')"
- name: Set up Git repository
uses: actions/checkout@v2
- name: Compile LaTeX document
uses: xu-cheng/latex-action@v2
with:
root_file: ${{env.FILE_NAME}}.tex
working_directory: ${{env.FILE_PATH}}
compiler: xelatex
- name: Upload artifact as workflow attachments
uses: actions/upload-artifact@v2
with:
name: result
path: ${{env.FILE_PATH}}${{env.FILE_NAME}}.pdf
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{secrets.TOKEN}}
with:
tag_name: DOC-${{steps.date.outputs.date}}
release_name: Release Doc ${{steps.date.outputs.date}}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.TOKEN}}
with:
upload_url: ${{steps.create_release.outputs.upload_url}}
asset_path: ${{env.FILE_PATH}}${{env.FILE_NAME}}.pdf
asset_name: ${{env.RESULT_NAME}}.pdf
asset_content_type: application/pdf
@bozzelliandrea
Copy link
Author

the following YML snippet, compile LaTex document (with xelatex compiler for this configuration) in PDF file.

The steps of the action are as follows:

  • compilation of the file from tex to pdf
  • attach the file initially to the workflow (optional step)
  • create a new release and tag with today's date
  • attach the file to the release.

the workflow is fully customizable to retrieve multiple files, change the compiler for the latex format or change file name and path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment