From fdc2d617db22994e1b5bf86ce3b2e80dfde59bcd Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Sat, 20 Apr 2024 00:02:27 -0400 Subject: [PATCH] Add GitHub Actions to compile the paper --- .github/workflows/build-latex-diff.yml | 44 ++++++++++++++++++++++++ .github/workflows/build-latex.yml | 47 ++++++++++++++++++++++++++ .github/workflows/pr-comment.yml | 20 +++++++++++ 3 files changed, 111 insertions(+) create mode 100644 .github/workflows/build-latex-diff.yml create mode 100644 .github/workflows/build-latex.yml create mode 100644 .github/workflows/pr-comment.yml diff --git a/.github/workflows/build-latex-diff.yml b/.github/workflows/build-latex-diff.yml new file mode 100644 index 0000000..b5a7c61 --- /dev/null +++ b/.github/workflows/build-latex-diff.yml @@ -0,0 +1,44 @@ +name: Build LaTeX diff document +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build_latex: + runs-on: ubuntu-latest + env: + PAPER: "main" + MAIN: ${{ github.event.pull_request.base.sha }} + steps: + - name: Set up Git repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Compile LaTeX diff + id: compileLaTeXdiff + uses: xu-cheng/latex-action@v3 + with: + root_file: | + ${{ env.PAPER }}-diff${{ env.MAIN }}.tex + working_directory: tex + extra_system_packages: "git patch" + latexmk_shell_escape: true + pre_compile: git config --global --add safe.directory /github/workspace && latexdiff-vc --git --flatten --disable-auto-mbox --exclude-safecmd="Cref,Cref\*,hspace" -r ${{ env.MAIN }} ${{ env.PAPER }}.tex + continue-on-error: true + - name: Upload PDF + if: steps.compileLaTeXdiff.outcome == 'success' + uses: actions/upload-artifact@v3 + with: + name: Success--Here-is-the-Diff-PDF + path: | + tex/${{ env.PAPER }}-diff${{ env.MAIN }}.pdf + - name: Upload build logs + if: steps.compileLaTeXdiff.outcome == 'failure' + uses: actions/upload-artifact@v3 + with: + name: Diff-Build-Failed--Here-are-the-Logs + path: | + tex/**/*.log + - name: Fail job if build failed + if: steps.compileLaTeXdiff.outcome == 'failure' + run: exit 1 diff --git a/.github/workflows/build-latex.yml b/.github/workflows/build-latex.yml new file mode 100644 index 0000000..891e813 --- /dev/null +++ b/.github/workflows/build-latex.yml @@ -0,0 +1,47 @@ +name: Build LaTeX document +on: + push: + branches: + - master + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build_latex: + runs-on: ubuntu-latest + env: + PAPER: "main" + steps: + - name: Set up Git repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Compile LaTeX document + id: compileLaTeXdocument + uses: xu-cheng/latex-action@v3 + with: + root_file: | + ${{ env.PAPER }}.tex + working_directory: tex + extra_system_packages: "git patch" + latexmk_shell_escape: true + pre_compile: git config --global --add safe.directory /github/workspace + continue-on-error: true + - name: Upload PDF + if: steps.compileLaTeXdocument.outcome == 'success' + uses: actions/upload-artifact@v3 + with: + name: Success--Here-is-the-PDF + path: | + tex/${{ env.PAPER }}.pdf + - name: Upload build logs + if: steps.compileLaTeXdocument.outcome == 'failure' + uses: actions/upload-artifact@v3 + with: + name: Build-Failed--Here-are-the-Logs + path: | + tex/**/*.log + - name: Fail job if build failed + if: steps.compileLaTeXdocument.outcome == 'failure' + run: exit 1 diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml new file mode 100644 index 0000000..d6e1d93 --- /dev/null +++ b/.github/workflows/pr-comment.yml @@ -0,0 +1,20 @@ +name: add artifact links to pr +on: + workflow_run: + workflows: ["Build LaTeX document", "Build LaTeX diff document"] + types: [completed] + +jobs: + artifacts-url-comments: + name: add artifact links to pull request and related issues job + runs-on: [ubuntu-latest] + steps: + - name: add artifact links to pull request and related issues step + if: needs.pr-check.outputs.number != null + uses: veitbjarsch/artifacts-url-comments@v1.1.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + prefix: "Status:" + format: "name" + addTo: "pull"