🏢

久しぶりにGitHub Pagesを更新したらGitHub Actionsのビルドが失敗した

に公開

発生した問題

久しぶりに職務経歴書を掲載しているGitHub Pagesのサイトを更新してpushしたところ、GitHub Actionsのビルドが失敗して以下のエラーが表示された。

This request has been automatically failed because it uses a deprecated version of actions/upload-artifact: v3. Learn more: https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/

エラーメッセージによると、actions/upload-artifact@v3が非推奨とのこと。

原因調査

エラーメッセージにあるGitHubブログの内容をChatGPTで要約した結果、以下の回答が出た。

2025年1月30日以降、GitHub Actionsでは
actions/upload-artifact および actions/download-artifact の v3 は使用できなくなります。そのため、できるだけ早く v4 に移行してください。

.github/workflows/jekyll-gh-pages.ymlを確認したがactions/upload-artifactactions/download-artifactは使用していなかった。

ビルドが失敗する原因を特定するため、GitHubのブログを色々見ていると以下の記事を発見した。
https://github.blog/changelog/2024-12-05-deprecation-notice-github-pages-actions-to-require-artifacts-actions-v4-on-github-com/

What You Need to Do
If your GitHub Page site is using a custom Actions workflow to deploy, it must be updated to use:

  • actions/upload-pages-artifact@v3
  • actions/deploy-pages@v4

actions/upload-pages-artifactactions/deploy-pagesがどちらもv1のままだったので最新のバージョンに更新する必要がありそう。

解決方法

  • upload-pages-artifact@v1v3に更新
  • deploy-pages@v1v4に更新
  • ついでにjekyll-build-pagesのREADMEにあるUsageを参考に、他のプロパティも最新バージョンに更新

最終的に.github/workflows/jekyll-gh-pages.ymlを以下の内容に修正した結果、ビルドに成功した。

# Sample workflow for building and deploying a Jekyll site to GitHub Pages
name: Deploy Jekyll with GitHub Pages dependencies preinstalled

on:
  # Runs on pushes targeting the default branch
  push:
    branches: ["main"]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow one concurrent deployment
concurrency:
  group: "pages"
  cancel-in-progress: true

jobs:
  # Build job
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
      - name: Setup Pages
-        uses: actions/configure-pages@v2
+        uses: actions/configure-pages@v5
      - name: Build with Jekyll
        uses: actions/jekyll-build-pages@v1
        with:
          source: ./
          destination: ./_site
      - name: Upload artifact
-        uses: actions/upload-pages-artifact@v1
+        uses: actions/upload-pages-artifact@v3

  # Deployment job
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
-        uses: actions/deploy-pages@v1
+        uses: actions/deploy-pages@v4

Discussion