-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (111 loc) · 5.05 KB
/
build-and-test.yml
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Build and Test
on:
push:
pull_request:
release:
types:
- published
- edited
schedule:
- cron: '15 1 * * 6'
jobs:
build-test-push:
runs-on: ubuntu-latest
env:
DOCKERHUB_USERNAME: gokhlayeh # used in non trustworthy section of the job
buildx_platforms: linux/amd64
steps:
# preparation
#
- name: Remove unused packages from disk
run: |
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
#
# build unstable image used for test suite
#
- name: Build testing image
uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: ./docker
file: ./docker/Dockerfile
load: true
push: false
tags: ${{ env.DOCKERHUB_USERNAME }}/latex:testing
#
# run test suite
#
- name: Compile EPS test document
run: docker run -v "$(pwd):/github/workspace" -w /github/workspace/test/eps ${{ env.DOCKERHUB_USERNAME }}/latex:testing latexmk -outdir=build -pdf -interaction=nonstopmode -file-line-error main.tex
- name: Compile FontAwesome5 test document
run: docker run -v "$(pwd):/github/workspace" -w /github/workspace/test/fontawesome5 ${{ env.DOCKERHUB_USERNAME }}/latex:testing latexmk -outdir=build -pdf -interaction=nonstopmode -file-line-error main.tex
- name: Symlink latexmkrc to root of workspace
run: ln -sf test/gnuplot/.latexmkrc
- name: Compile GNUPlot test document
run: docker run -v "$(pwd):/github/workspace" -w /github/workspace/test/gnuplot ${{ env.DOCKERHUB_USERNAME }}/latex:testing latexmk -outdir=build -pdf -interaction=nonstopmode -file-line-error main.tex
- name: Compile pdf2svg test document
run: docker run -v "$(pwd):/github/workspace" -w /github/workspace/test/pdf2svg ${{ env.DOCKERHUB_USERNAME }}/latex:testing latexmk -outdir=. -pdf -interaction=nonstopmode -file-line-error main.tex
- name: Compile PlantUML test document
run: docker run -v "$(pwd):/github/workspace" -w /github/workspace/test/plantuml ${{ env.DOCKERHUB_USERNAME }}/latex:testing latexmk -outdir=. -pdf -lualatex -interaction=nonstopmode -file-line-error main.tex
- name: Compile PythonTeX test document
run: docker run -v "$(pwd):/github/workspace" -w /github/workspace/test/pythontex ${{ env.DOCKERHUB_USERNAME }}/latex:testing latexmk -outdir=build -pdf -interaction=nonstopmode -file-line-error main.tex
- name: Compile SVG test document
run: docker run -v "$(pwd):/github/workspace" -w /github/workspace/test/svg ${{ env.DOCKERHUB_USERNAME }}/latex:testing latexmk -outdir=build -pdf -interaction=nonstopmode -file-line-error main.tex
#
# push image (if trusted commit)
#
- name: Login to DockerHub
if: ${{ github.event_name == 'release' || ((github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/master') }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push unstable
if: ${{ github.event_name == 'release' || ((github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/master') }}
id: docker_build
uses: docker/build-push-action@v6
with:
context: ./docker
file: ./docker/Dockerfile
platforms: ${{ env.buildx_platforms }}
load: false
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/latex:unstable
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Determine release tag name
if: ${{ github.event_name == 'release' }}
id: vars
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:10})
- name: Build and push release
if: ${{ github.event_name == 'release' }}
uses: docker/build-push-action@v6
with:
context: ./docker
file: ./docker/Dockerfile
platforms: ${{ env.buildx_platforms }}
load: false
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/latex:${{steps.vars.outputs.tag}},
${{ secrets.DOCKERHUB_USERNAME }}/latex:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Update Docker Hub description
if: ${{ github.event_name == 'release' || (github.event_name == 'push' && github.ref == 'refs/heads/master') }}
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
readme-filepath: README.md
repository: ${{ secrets.DOCKERHUB_USERNAME }}/latex