先日、自分の履歴書情報を整理しようと思い、いつもの習慣通り LaTeX で作成しました。 しかし、オンラインで公開して履歴書のリンクを共有したいとき、PDF をどこかにアップロードする必要がありました。

履歴書の PDF ファイルはバイナリファイルであり、リポジトリに直接保存したくありませんでした。 そこで、GitHub Actions を利用して LaTeX ファイルを自動的にコンパイルし、生成された PDF を GitHub Pages に公開することにしました。

いくつかのテストの後、xu-cheng/latex-action を使用して Actions で PDF ファイルのコンパイルに成功しました。

 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
# https://github.com/ringsaturn/latex-to-pages-demo/blob/main/.github/workflows/build.yml
name: Compile

concurrency:
  group: "pages"
  cancel-in-progress: true

on:
  push:
    branches: main
  pull_request:
    branches: main

jobs:
  make-pdf:
    runs-on: ubuntu-latest
    timeout-minutes: 10

    steps:
      - uses: actions/checkout@v4
      - name: Compile LaTeX (XeLaTeX)
        uses: xu-cheng/latex-action@v4
        with:
          root_file: |
            main-en.tex
            main-zh.tex
            main-ja.tex

          texlive_version: 2025
          latexmk_use_xelatex: true  # To support CJK characters
          extra_system_packages: "fontconfig font-noto-cjk font-noto-cjk-extra"

      - name: Move PDFs to public directory
        run: |
          mv *.pdf public/

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: public/

  deploy:
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    permissions:
      contents: read
      pages: write
      id-token: write
    if: github.ref == 'refs/heads/main'
    needs: make-pdf
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

サンプルリポジトリは ringsaturn/latex-to-pages-demo です。

結果: