|
12 | 12 |
|
13 | 13 | jobs:
|
14 | 14 | build-by-miktex:
|
15 |
| - name: Build by MiKTeX |
16 |
| - runs-on: ubuntu-22.04 |
17 |
| - env: |
18 |
| - APT_LIST: "" ## Evaluated at runtime |
19 |
| - ROOT_FILE: "" |
20 |
| - OUTPUT_FILE: "" |
21 |
| - strategy: |
22 |
| - matrix: |
23 |
| - target: [notes, cheatsheet] |
24 |
| - steps: |
25 |
| - - name: Checkout repository |
26 |
| - uses: actions/checkout@v4 |
27 |
| - ## Configure GPG key |
28 |
| - - name: Configure MiKTeX GPG key |
29 |
| - run: | |
30 |
| - curl -fsSL https://miktex.org/download/key | sudo tee /usr/share/keyrings/miktex-keyring.asc > /dev/null |
31 |
| - echo "deb [signed-by=/usr/share/keyrings/miktex-keyring.asc] https://miktex.org/download/ubuntu jammy universe" | sudo tee /etc/apt/sources.list.d/miktex.list |
32 |
| - ## Prepare the environment |
33 |
| - - name: Get dependencies list |
34 |
| - run: echo "APT_LIST=$(awk '{$1=$1}1' OFS=' ' RS='' build/apt-list.txt)" >> "$GITHUB_ENV" |
35 |
| - - name: Include disclaimer header |
36 |
| - run: | |
37 |
| - chmod +x ./build/add-disclaimer.sh |
38 |
| - ./build/add-disclaimer.sh |
39 |
| - ## Install MiKTeX |
40 |
| - - name: Install MiKTeX and dependencies |
41 |
| - id: apt-install |
42 |
| - uses: awalsh128/cache-apt-pkgs-action@v1 |
43 |
| - with: |
44 |
| - packages: ${{ env.APT_LIST }} |
45 |
| - - uses: actions/setup-python@v5 |
46 |
| - with: |
47 |
| - python-version: '3.13' |
48 |
| - cache: 'pip' |
49 |
| - - name: Install Python packages |
50 |
| - run: | |
51 |
| - python -m pip install --upgrade pip |
52 |
| - pip install -r build/requirements.txt |
53 |
| - ## Restore LaTeX packages cache if apt was cached |
54 |
| - - name: Restore LaTeX packages from cache |
55 |
| - id: miktex-cache |
56 |
| - if: ${{ steps.apt-install.outputs.cache-hit == 'true' }} |
57 |
| - uses: actions/cache/restore@v4 |
58 |
| - with: |
59 |
| - key: miktex-pkg-${{ runner.os }}-${{ hashFiles(format('./{0}/packages.tex', matrix.target)) }} |
60 |
| - path: ~/.miktex |
61 |
| - ## Finish MiKTeX setup |
62 |
| - - name: Finish MiKTeX setup |
63 |
| - run: | |
64 |
| - miktexsetup finish |
65 |
| - initexmf --set-config-value [MPM]AutoInstall=1 |
66 |
| - initexmf --enable-installer |
67 |
| - initexmf --update-fndb |
68 |
| - initexmf --mkmaps |
69 |
| - - name: Fix PATH |
70 |
| - run: echo "PATH=$HOME/bin:$PATH" >> "$GITHUB_ENV" |
71 |
| - ## Compile the document |
72 |
| - - name: Get root file |
73 |
| - run: echo "ROOT_FILE=`(ls ${{ matrix.target }} | grep -E "COMP2120-.*\.tex")`" >> "$GITHUB_ENV" |
74 |
| - - name: Compile target - ${{ matrix.target }} |
75 |
| - id: compile |
76 |
| - run: | |
77 |
| - latexmk -shell-escape -interaction=nonstopmode -pdf -cd -outdir=. -f ./${{ matrix.target }}/${{ env.ROOT_FILE }} |
78 |
| - mv ./${{ matrix.target }}/${{ env.ROOT_FILE }} . |
79 |
| - ## Cache the MiKTeX packages if apt cache or miktex cache did not hit |
80 |
| - - name: Cache MiKTeX packages |
81 |
| - if: ${{ !(steps.apt-install.outputs.cache-hit == 'true' && steps.miktex-cache.outputs.cache-hit) }} |
82 |
| - uses: actions/cache/save@v4 |
83 |
| - with: |
84 |
| - key: miktex-pkg-${{ runner.os }}-${{ hashFiles(format('./{0}/packages.tex', matrix.target)) }} |
85 |
| - path: ~/.miktex |
86 |
| - ## Upload the artifact |
87 |
| - - name: Find output file |
88 |
| - run: echo "OUTPUT_FILE=`(ls ${{ matrix.target }} | grep -E "COMP2120-.*\.pdf")`" >> "$GITHUB_ENV" |
89 |
| - - name: Upload artifact |
90 |
| - uses: actions/upload-artifact@v4 |
91 |
| - with: |
92 |
| - name: pdf-miktex-${{ matrix.target }} |
93 |
| - path: ${{ matrix.target}}/${{ env.OUTPUT_FILE }} |
94 |
| - retention-days: 1 |
95 |
| - ## Upload logs |
96 |
| - - name: Upload compile logs |
97 |
| - if: ${{ always() }} |
98 |
| - uses: actions/upload-artifact@v4 |
99 |
| - with: |
100 |
| - name: logs-miktex-${{ matrix.target }} |
101 |
| - path: /home/runner/.miktex/texmfs/data/miktex/log/ |
102 |
| - retention-days: 14 |
| 15 | + name: Build by MiKTeX |
| 16 | + runs-on: ubuntu-22.04 |
| 17 | + if: ${{ !contains(github.event.head_commit.message, '@nobuild') }} |
| 18 | + env: |
| 19 | + APT_LIST: "" ## Evaluated at runtime |
| 20 | + ROOT_FILE: "" |
| 21 | + OUTPUT_FILE: "" |
| 22 | + strategy: |
| 23 | + matrix: |
| 24 | + target: [notes, cheatsheet] |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + ## Configure GPG key |
| 29 | + - name: Configure MiKTeX GPG key |
| 30 | + run: | |
| 31 | + curl -fsSL https://miktex.org/download/key | sudo tee /usr/share/keyrings/miktex-keyring.asc > /dev/null |
| 32 | + echo "deb [signed-by=/usr/share/keyrings/miktex-keyring.asc] https://miktex.org/download/ubuntu jammy universe" | sudo tee /etc/apt/sources.list.d/miktex.list |
| 33 | + ## Prepare the environment |
| 34 | + - name: Get dependencies list |
| 35 | + run: echo "APT_LIST=$(awk '{$1=$1}1' OFS=' ' RS='' build/apt-list.txt)" >> "$GITHUB_ENV" |
| 36 | + - name: Include disclaimer header |
| 37 | + run: | |
| 38 | + chmod +x ./build/add-disclaimer.sh |
| 39 | + ./build/add-disclaimer.sh |
| 40 | + ## Install MiKTeX |
| 41 | + - name: Install MiKTeX and dependencies |
| 42 | + id: apt-install |
| 43 | + uses: awalsh128/cache-apt-pkgs-action@v1 |
| 44 | + with: |
| 45 | + packages: ${{ env.APT_LIST }} |
| 46 | + - uses: actions/setup-python@v5 |
| 47 | + with: |
| 48 | + python-version: '3.13' |
| 49 | + cache: 'pip' |
| 50 | + - name: Install Python packages |
| 51 | + run: | |
| 52 | + python -m pip install --upgrade pip |
| 53 | + pip install -r build/requirements.txt |
| 54 | + ## Restore LaTeX packages cache if apt was cached |
| 55 | + - name: Restore LaTeX packages from cache |
| 56 | + id: miktex-cache |
| 57 | + if: ${{ steps.apt-install.outputs.cache-hit == 'true' }} |
| 58 | + uses: actions/cache/restore@v4 |
| 59 | + with: |
| 60 | + key: miktex-pkg-${{ runner.os }}-${{ hashFiles(format('./{0}/packages.tex', matrix.target)) }} |
| 61 | + path: ~/.miktex |
| 62 | + ## Finish MiKTeX setup |
| 63 | + - name: Finish MiKTeX setup |
| 64 | + run: | |
| 65 | + miktexsetup finish |
| 66 | + initexmf --set-config-value [MPM]AutoInstall=1 |
| 67 | + initexmf --enable-installer |
| 68 | + initexmf --update-fndb |
| 69 | + initexmf --mkmaps |
| 70 | + - name: Fix PATH |
| 71 | + run: echo "PATH=$HOME/bin:$PATH" >> "$GITHUB_ENV" |
| 72 | + ## Compile the document |
| 73 | + - name: Get root file |
| 74 | + run: echo "ROOT_FILE=`(ls ${{ matrix.target }} | grep -E "COMP2120-.*\.tex")`" >> "$GITHUB_ENV" |
| 75 | + - name: Compile target - ${{ matrix.target }} |
| 76 | + id: compile |
| 77 | + run: | |
| 78 | + latexmk -shell-escape -interaction=nonstopmode -pdf -cd -outdir=. -f ./${{ matrix.target }}/${{ env.ROOT_FILE }} |
| 79 | + mv ./${{ matrix.target }}/${{ env.ROOT_FILE }} . |
| 80 | + ## Cache the MiKTeX packages if apt cache or miktex cache did not hit |
| 81 | + - name: Cache MiKTeX packages |
| 82 | + if: ${{ !(steps.apt-install.outputs.cache-hit == 'true' && steps.miktex-cache.outputs.cache-hit) }} |
| 83 | + uses: actions/cache/save@v4 |
| 84 | + with: |
| 85 | + key: miktex-pkg-${{ runner.os }}-${{ hashFiles(format('./{0}/packages.tex', matrix.target)) }} |
| 86 | + path: ~/.miktex |
| 87 | + ## Upload the artifact |
| 88 | + - name: Find output file |
| 89 | + run: echo "OUTPUT_FILE=`(ls ${{ matrix.target }} | grep -E "COMP2120-.*\.pdf")`" >> "$GITHUB_ENV" |
| 90 | + - name: Upload artifact |
| 91 | + uses: actions/upload-artifact@v4 |
| 92 | + with: |
| 93 | + name: pdf-miktex-${{ matrix.target }} |
| 94 | + path: ${{ matrix.target}}/${{ env.OUTPUT_FILE }} |
| 95 | + retention-days: 1 |
| 96 | + ## Upload logs |
| 97 | + - name: Upload compile logs |
| 98 | + if: ${{ always() }} |
| 99 | + uses: actions/upload-artifact@v4 |
| 100 | + with: |
| 101 | + name: logs-miktex-${{ matrix.target }} |
| 102 | + path: /home/runner/.miktex/texmfs/data/miktex/log/ |
| 103 | + retention-days: 14 |
103 | 104 | deploy:
|
104 | 105 | name: Build and deploy static site
|
105 | 106 | runs-on: ubuntu-latest
|
|
0 commit comments