JekyllのIncremental Regenerationを試してみたいので、GitHub Actionsがビルド結果のファイルをどのように扱うのか確認してみました。

  • Incremental Regenerationを利用するには、GitHub Actionsによる前回のビルドから、./_site/以下のアーティファクトと./.jekyll-metadataファイルを引き継いで、今回のビルドのために展開する、また、
  • 新しいポストを検出するためには、どうにかしてjekyll buildコマンドに新しいポストのリストを教えてもらうか、./.jekyll-metadataファイルなどの変化を検出する

必要がありそうです。

ローカルでのビルド

Incremental Regenerationでは.jekyll-metadataファイルに前回のビルド結果を保存するとのことです。このファイルはトップディレクトリに生成され、メタデータにはフルパスが含まれるようです。

$ bundle exec jekyll build -I
$ ruby -rpp -e 'pp Marshal.load(File.read(".jekyll-metadata")).first'
["/home/zunda/c/src/github.com/zunda/zunda.github.io/_posts/2026-01-14-welcome-to-jekyll.md",
 {"mtime" => 2026-01-14 14:34:52.872091488 -1000,
  "deps" =>
   ["/home/zunda/c/src/github.com/zunda/zunda.github.io/vendor/bundle/ruby/4.0.0/gems/minima-2.5.2/_layouts/post.html",
    "/home/zunda/c/src/github.com/zunda/zunda.github.io/vendor/bundle/ruby/4.0.0/gems/minima-2.5.2/_includes/head.html",
    "/home/zunda/c/src/github.com/zunda/zunda.github.io/vendor/bundle/ruby/4.0.0/gems/minima-2.5.2/_includes/header.html",
    "/home/zunda/c/src/github.com/zunda/zunda.github.io/vendor/bundle/ruby/4.0.0/gems/minima-2.5.2/_includes/footer.html",
    "/home/zunda/c/src/github.com/zunda/zunda.github.io/vendor/bundle/ruby/4.0.0/gems/minima-2.5.2/_includes/social.html",
    "/home/zunda/c/src/github.com/zunda/zunda.github.io/vendor/bundle/ruby/4.0.0/gems/minima-2.5.2/_layouts/default.html"]}]

GitHub Actionsによるビルド

GitHub Pagesにこのサイトを公開してもらってGitHub.comのユーザーインターフェースからGitHub ActionsのbuildジョブのBuild with jekyllステップログを確認すると、カレントディレクトリはいつも同じのようです。

Run bundle exec jekyll build --baseurl ""
Configuration file: /home/runner/work/zunda.github.io/zunda.github.io/_config.yml
            Source: /home/runner/work/zunda.github.io/zunda.github.io
       Destination: /home/runner/work/zunda.github.io/zunda.github.io/_site

GitHub Actionsによるアーティファクト

GitHub Pagesにこのサイトを公開してもらってGitHub.comのユーザーインターフェースからGitHub Actionsのログを確認すると、アーティファクトをダウンロードできることに気づきました。Tarファイルをzipしたもので、内容はローカルでbundle exec jekyll serveした時に_site/ディレクトリに生成されるものと同様のようです。

$ unzip ~/Downloads/github-pages.zip
$ tar xf artifact.tar
$ tree .
.
├── 404.html
├── about
│   └── index.html
├── artifact.tar
├── assets
│   ├── main.css
│   ├── main.css.map
│   └── minima-social-icons.svg
├── feed.xml
├── index.html
└── jekyll
    └── update
        └── 2026
            └── 01
                └── 14
                    └── welcome-to-jekyll.html

8 directories, 9 files

このアーティファクトは、buildジョブのUpload artifactステップでアップロードされ、deployジョブのDeploy to GitHub Pagesステップでダウンロードされるものと同一のハッシュのようです。