0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GitHub Pages で LaTeX コンパイルした PDF をホスティングする

Posted at

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

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

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

# 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 です。

結果:

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?