Skip to content

Ch6 formula corrections #240

Ch6 formula corrections

Ch6 formula corrections #240

Workflow file for this run

name: Build document
on:
push:
tags: ["*"]
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Update Title
run: |
sudo apt install imagemagick fonts-freefont-ttf
export TEXT_FONT=FreeSans-Bold
export TEXT_SIZE=96
export TEXT_COLOR=LightGray
export TEXT="v $(git describe --tags)"
mogrify -stroke Black -fill Black -draw "rectangle 1090,2300 1390,2400" -stroke ${TEXT_COLOR} -fill ${TEXT_COLOR} -font ${TEXT_FONT} -pointsize ${TEXT_SIZE} -gravity Center -draw "text 0,600 '${TEXT}'" figures/MMM_cover.jpg
- name: LaTeX pass 1
uses: xu-cheng/latex-action@v2
with:
pre_compile: ./install_sagetex_sty.sh
compiler: pdflatex
args: --shell-escape
root_file: main-moonmath.tex
- name: LaTeX pass 2
uses: xu-cheng/latex-action@v2
with:
compiler: pdflatex
args: --shell-escape
root_file: main-moonmath.tex
- name: SageMath pass
uses: wuan/sagemath-action@v1
with:
source_file: main-moonmath.sagetex.sage
- name: LaTeX final iterations
id: latex-final
uses: xu-cheng/latex-action@v2
with:
root_file: main-moonmath.tex
- name: Collect Warnings
id: warnings
run: |
echo "WARNINGS<<EOF" >> $GITHUB_ENV
grep "^LaTeX Warning" main-moonmath.log | cut -d" " -f3- | tee -a $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
continue-on-error: true
- name: Upload PDF
uses: actions/upload-artifact@v3
with:
name: MoonMath Manual PDF
path: main-moonmath.pdf
- name: Upload generated files
uses: actions/upload-artifact@v3
with:
name: MoonMath Manual generated files
path: |
tmp/*
sage-plots-for-main-moonmath.tex/*
- name: Update PR with warnings found
uses: actions/github-script@v6
continue-on-error: true
if: github.event_name == 'pull_request'
env:
WARNINGS: "${{ env.WARNINGS }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// 1. Retrieve existing bot comments for the PR
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
const botComment = comments.find(comment => {
return comment.user.type === 'Bot' && comment.body.includes('Moonmath Manual build')
})
// 2. Prepare format of the comment
const output = `#### Moonmath Manual build
<details><summary>WARNINGS</summary>\n\n
\`\`\`
${process.env.WARNINGS}
\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
// 3. If we have a comment, update it, otherwise create a new one
const comment_data = {
owner: context.repo.owner,
repo: context.repo.repo,
body: output
}
if (botComment) {
comment_data.comment_id = botComment.id
github.rest.issues.updateComment(comment_data)
} else {
comment_data.issue_number = context.issue.number
github.rest.issues.createComment(comment_data)
}
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
if: startsWith(github.ref, 'refs/tags/')
with:
name: Release ${{ github.ref_name }}
artifacts: main-moonmath.pdf
artifactContentType: application/pdf