Skip to content

Commit

Permalink
Update: skip compiling svg when not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
HuangFuSL committed Sep 17, 2023
1 parent c879d05 commit 29717a1
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: |
chown -R root:root $PWD
. /root/venv/bin/activate
python3 ./ci/deploy.py --dry-run
make build
- name: Save artifact
uses: actions/upload-artifact@v3
Expand All @@ -60,4 +60,4 @@ jobs:
chown -R root:root $PWD
. /root/venv/bin/activate
git checkout main && git pull
python3 ./ci/deploy.py
make deploy
26 changes: 26 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@ jobs:
deploy: true
secrets: inherit

detect:
name: Detect changed LaTeX files
runs-on: ubuntu-latest
needs: deploy
outputs:
changed: ${{ steps.detect.outputs.changed }}
steps:
- name: Checkout gh-pages
uses: actions/checkout@v4

- name: Detect changed files
id: detect
run:
if git diff HEAD^ HEAD --name-only | grep '.tex$'; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi

latex:
name: Compile LaTeX files
needs: detect
if: needs.detect.outputs.changed == 'true'
uses: ./.github/workflows/latex.yml
secrets: inherit

metrics:
name: Update metrics
needs: deploy
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/latex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Compile LaTeX files

on:
workflow_call:

jobs:
compile:
name: Compile LaTeX files
runs-on: ubuntu-latest
container:
image: ghcr.io/huangfusl/template:latest
options: --user root
steps:

- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
fetch-depth: 1
path: '.'

- name: Compile LaTeX files
run: |
make -f /opt/template/makefile.latex.template svg
- name: Push changes
run: |
cd $GITHUB_WORKSPACE
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git pull
git add .
git commit -m "Update svg files - [Skip GitHub Action]"
git push
20 changes: 2 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
# From TeXLive image
FROM registry.gitlab.com/islandoftex/images/texlive:TL2023-2023-08-13-full
FROM python:bullseye

# Reconfigure dependencies
RUN sed -i 's/testing/stable/g' /etc/apt/sources.list \
&& apt-get update \
&& apt-get remove -y \
nodejs \
ghostscript \
python3 \
&& apt-get autoremove -y \
&& apt-get install -y \
nodejs \
ghostscript \
python3 \
python3-pip \
python3-venv \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install dependencies
COPY ./requirements.txt /tmp/requirements.txt
# Create a virtual environment, activate it and install dependencies
RUN python3 -m venv /root/venv \
Expand Down
12 changes: 12 additions & 0 deletions docs/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
_BUILD:
python3 -m mkdocs build -d build --clean

_DEPLOY:
python3 -m mkdocs gh-deploy -d build --message $(shell date "+%Y-%m-%d %H:%M:%S")

_CONVERT:
make -f third_party/template/makefile.latex.template svg

convert: _CONVERT
build: _BUILD
deploy: | build _DEPLOY
13 changes: 0 additions & 13 deletions makefile

This file was deleted.

1 change: 1 addition & 0 deletions makefile

0 comments on commit 29717a1

Please sign in to comment.