GitHub Actions の環境で、LaTeX記法の日本語表示できるようにする #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PR を作成したら、PDF を作成して、その PDF を PR に添付する。 | |
# 作成される PDF は電子版向けです。 | |
name: Build and Attach PDF on Pull-Request | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
build-and-attach-pdf-on-pr: | |
runs-on: ubuntu-latest | |
# 環境変数を定義 | |
env: | |
# 生成される PDF のパス | |
PDF_PATH: ./book/output/ebook.pdf | |
steps: | |
# フォントをキャッシュ&リストアする | |
- name: Restore or Save Cache Font Noto | |
id: cache-font-noto | |
uses: actions/cache@v4 | |
with: | |
path: /usr/share/fonts/opentype/noto | |
key: font-noto-cache-key | |
# 日本語をインストールする | |
- name: Install Japanese fonts | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y fonts-noto-cjk fonts-noto-cjk-extra | |
if: ${{ steps.cache-font-noto.outputs.cache-hit != 'true' }} | |
# リポジトリをチェックアウト | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Node.js をセットアップ | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.node-version' | |
# PDF を作成する | |
- name: make PDF | |
run: | | |
corepack enable | |
yarn install --frozen-lockfile | |
yarn build | |
# PDF が生成されたかどうかをチェックする | |
- name: Check if PDF exists | |
run: | | |
if [ ! -f "${PDF_PATH}" ]; then | |
echo "エラー: PDF の生成に失敗しました。" | |
exit 1 | |
fi | |
# アーティファクトとして PDF をアップロードする | |
- name: Upload PDF as artifact | |
uses: actions/upload-artifact@v4 | |
id: artifact-upload-step | |
with: | |
name: "ebook-pdf" | |
path: "${{ env.PDF_PATH }}" | |
if-no-files-found: error | |
# PR に PDF のアーティファクトリンクを含むコメントを投稿する | |
- name: Create PR Comment | |
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
:page_facing_up: PDF が作成されました | |
[ダウンロード](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }}) |