Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 27, 2025

最新バージョン(v4)のupload-pages-artifactでは、隠しファイル(特にドットファイル)がアーティファクトに含まれなくなる破壊的変更が加えられました。これにより、Jekyll で生成されるような隠しファイル(.nojekyll.htaccess など)が GitHub Pages のデプロイメントから除外され、正常に動作しない可能性があります。

この問題を解決するため、upload-pages-artifact@v3 から upload-artifact@v4 への移行を実施し、GitHub Pages の要件を満たすように適切な tar.gz 形式でアーティファクトを作成するようにしました。

変更内容

.github/workflows/gh-pages.yml

Before:

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

After:

- name: Archive artifact
  shell: sh
  run: |
    echo "::group::Archive artifact"
    tar \
      --dereference --hard-dereference \
      --directory "_site" \
      -czf "$RUNNER_TEMP/github-pages.tar.gz" \
      .
    echo "::endgroup::"
- name: Upload artifact
  uses: actions/upload-artifact@v4
  with:
    name: github-pages
    path: ${{ runner.temp }}/github-pages.tar.gz
    retention-days: 1
    if-no-files-found: error

また、deploy ジョブでも対応する変更を行い、新しいアーティファクト名を指定するようにしました:

- uses: actions/deploy-pages@v4
  id: deployment
  with:
    artifact-name: github-pages

主な改善点

  1. GitHub Pages 要件の遵守: アーティファクトが単一の tar ファイルを含む gzip アーカイブとして作成され、"github-pages" という名前で識別されます
  2. 隠しファイルの保持: tar の --dereference --hard-dereference オプションにより、Jekyll が生成する重要な隠しファイルが確実に含まれるようになります
  3. 適切な保持期間: retention-days: 1 により、不要なストレージ使用を避けながら必要な期間(24時間)アーティファクトを保持します
  4. エラーハンドリング: if-no-files-found: error により、ファイルが見つからない場合に明確にエラーとして扱われます
  5. 最新バージョンの使用: upload-artifact@v4 の使用により、最新の機能とセキュリティ修正の恩恵を受けられます

この変更により、GitHub Pages のドキュメントデプロイメントが引き続き正常に動作し、隠しファイルも適切に処理されるようになります。

Fixes #845.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Migrate from upload-pages-artifact to upload-artifact due to breaking changes Migrate from upload-pages-artifact to upload-artifact due to breaking changes Aug 27, 2025
Copilot AI requested a review from SorrowBlue August 27, 2025 17:38
Copilot finished work on behalf of SorrowBlue August 27, 2025 17:38
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot
次の条件を満たす必要があります。

なお、upload-pages-artifactでは以下のようた方法でartifact.tarを作成しています。

- name: Archive artifact
      shell: sh
      if: runner.os == 'macOS'
      run: |
        echo ::group::Archive artifact
        gtar \
          --dereference --hard-dereference \
          --directory "$INPUT_PATH" \
          -cvf "$RUNNER_TEMP/artifact.tar" \
          .
        echo ::endgroup::
      env:
        INPUT_PATH: ${{ inputs.path }}

retention-daysは一日(24時間)にしてください
if-no-files-foundはerrorにしてください

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub Pages の要件に合わせて、単一の gzip アーカイブとして tar ファイルを作成するように修正しました。retention-days: 1if-no-files-found: error の設定も追加しています。コミット: 8d9e8f7

Copilot AI changed the title Migrate from upload-pages-artifact to upload-artifact due to breaking changes Create proper tar.gz format for GitHub Pages artifact with required settings Aug 27, 2025
Copilot AI requested a review from SorrowBlue August 27, 2025 18:51
Copilot finished work on behalf of SorrowBlue August 27, 2025 18:51
@SorrowBlue SorrowBlue marked this pull request as ready for review August 27, 2025 19:15
@SorrowBlue SorrowBlue added the type: ⚙️chore 「ビルド、CI/CD、依存関係更新など」[Build, CI/CD, dependency updates, etc.] label Aug 27, 2025
@SorrowBlue SorrowBlue merged commit 5cb9132 into main Aug 27, 2025
@SorrowBlue SorrowBlue deleted the copilot/fix-845 branch August 27, 2025 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: ⚙️chore 「ビルド、CI/CD、依存関係更新など」[Build, CI/CD, dependency updates, etc.]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate from upload-pages-artifact to upload-artifact due to breaking changes

2 participants