fix #30
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: latex | |
on: push | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
filename: ${{ steps.filename.outputs.FILENAME }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Pull image" | |
run: | | |
docker pull ghcr.io/hiroyaonoe/texlive:latest | |
- name: "Run latexmk" | |
id: latexmk | |
run: docker run --mount type=bind,src=${{ github.workspace }},dst=/work ghcr.io/hiroyaonoe/texlive:latest latexmk | |
- name: "Output log if failure" | |
if: failure() && steps.latexmk.outcome == 'failure' | |
run: cat main.log | |
- name: "Set filename" | |
id: filename | |
run: | | |
COMMIT_HASH=$(git rev-parse --short ${{ github.sha }}) | |
FILENAME=${GITHUB_REPOSITORY#${GITHUB_REPOSITORY_OWNER}/}_main_${COMMIT_HASH} | |
echo "FILENAME=${FILENAME}" >> $GITHUB_OUTPUT | |
- name: "Commit and Push main.pdf" | |
run: | | |
git config user.name "$(git --no-pager log --format=format:'%an' -n 1)" | |
git config user.email "$(git --no-pager log --format=format:'%ae' -n 1)" | |
git fetch | |
if git branch -a | grep -q "remotes/origin/main-pdf"; then | |
git checkout -t origin/main-pdf | |
else | |
git checkout --orphan main-pdf | |
fi | |
git add -f main.pdf | |
git commit -m "main.pdf: ${{ github.sha }}" | |
git push origin main-pdf | |
- name: "Rename main.pdf" | |
run: mv main.pdf ${{ steps.filename.outputs.FILENAME }}.pdf | |
- name: "Upload artifact main.pdf" | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ steps.filename.outputs.FILENAME }} | |
path: ${{ steps.filename.outputs.FILENAME }}.pdf | |
release: | |
runs-on: ubuntu-latest | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- uses: actions/checkout@v2 | |
- name: "Set filename" | |
id: filename | |
run: | | |
FILENAME=${GITHUB_REPOSITORY#${GITHUB_REPOSITORY_OWNER}/}_main_${GITHUB_REF/refs\/tags\//}.pdf | |
echo "FILENAME=${FILENAME}" >> $GITHUB_OUTPUT | |
- name: "Download artifact main.pdf" | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ needs.build.outputs.filename }} | |
- name: "Rename main.pdf" | |
run: mv ${{ needs.build.outputs.filename }}.pdf ${{ steps.filename.outputs.FILENAME }} | |
- name: "Release" | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: ${{ steps.filename.outputs.FILENAME }} |