-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (73 loc) · 2.71 KB
/
latex.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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: |
mv main.pdf main_tmp.pdf
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
git rm --cached -r .
fi
mv main_tmp.pdf main.pdf
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 }}