Last active
March 30, 2022 16:00
-
-
Save hrialan/c74a3382e1bd02c32ebbd790a883ac22 to your computer and use it in GitHub Desktop.
[Build latex workflow] Build latex document and push it to gh-pages branch #latex #workflow
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: Build LaTeX document | |
on: [push] | |
jobs: | |
build_latex: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Git repository | |
uses: actions/checkout@v2 | |
- name: Compile LaTeX document | |
uses: xu-cheng/latex-action@v2 | |
with: | |
root_file: main.tex | |
- name: upload created pdf to artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: main.pdf | |
path: main.pdf | |
- name: Commit files to branch 'gh-pages' for public website | |
if: github.ref == 'refs/heads/master' | |
run: | | |
git config --local user.email "github-actions-bot@users.noreply.github.com" | |
git config --local user.name "github-actions-bot" | |
git checkout -b gh-pages | |
shopt -s extglob | |
rm -r !(main.pdf) | |
git rm -r --cached . | |
git add -f main.pdf | |
touch index.html | |
echo "<meta http-equiv="refresh" content=\"0; URL=./main.pdf\">" >> index.html | |
git add index.html | |
git commit -m "New PDF added" | |
- name: Push changes to branch 'gh-pages' | |
if: github.ref == 'refs/heads/master' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: gh-pages | |
force: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment