Skip to content

Avoid upload-pages-artifact action in GitHub Pages workflow#3502

Merged
justinmayer merged 2 commits intomainfrom
remove-upload-pages-artifact
Oct 16, 2025
Merged

Avoid upload-pages-artifact action in GitHub Pages workflow#3502
justinmayer merged 2 commits intomainfrom
remove-upload-pages-artifact

Conversation

@seanh
Copy link
Contributor

@seanh seanh commented Oct 4, 2025

In upload-pages-artifact@v4 the maintainers have made the curious decision to omit hidden files (files whose names begin with ".") from the site that gets deployed to GitHub Pages and to provide no way to include a hidden file (at least "for now"), even though static sites may of course want to include files whose names begin with "." actions/upload-pages-artifact#102

Work around this in by creating the "artifact" (tar file) ourselves and uploading it using the upload-artifact action, as suggested in the upload-pages-artifact PR linked above.

Context

GitHub's upload-pages-artifact action is really just a lightweight wrapper for their upload-artifact action. The upload-pages-artifact action does two things:

  1. It runs a tar command to create a tar file of your directory (in our case: Pelican's output directory)
  2. It calls upload-artifact to upload the tar file to GitHub Pages

In upload-pages-artifact@v4 they've added a --exclude option to the tar command that causes any hidden files in Pelican's output dir to be omitted from the tar file and therefore ultimately omitted from the GitHub Pages site that gets deployed.

In this PR I've removed upload-pages-artifact from our workflow in favour of just running our own tar command without the new --exclude and then calling upload-artifact ourselves.

@seanh seanh marked this pull request as draft October 4, 2025 11:03
seanh added a commit to seanh/ghp-pelican-demo that referenced this pull request Oct 4, 2025
In upload-pages-artifact@v4 the maintainers have made the curious
decision to omit hidden files (files whose names begin with ".") from
the site that gets deployed to GitHub Pages and to provide no way to
include a hidden file (at least "for now"), even though static sites may
of course want to include files whose names begin with "."

actions/upload-pages-artifact#102

Work around this in by creating the "artifact" (tar file) ourselves and
uploading it using the upload-artifact action, as suggested in the
upload-pages-artifact PR linked above.
@seanh seanh force-pushed the remove-upload-pages-artifact branch from 070a64c to 07d964f Compare October 4, 2025 11:08
Comment on lines +88 to +102
- name: Archive artifact
shell: sh
run: |
echo "::group::Archive artifact"
tar \
--dereference \
--hard-dereference \
--directory "$OUTPUT_PATH" \
-cvf "$RUNNER_TEMP/artifact.tar" \
--exclude=.git \
--exclude=.github \
.
echo "::endgroup::"
env:
OUTPUT_PATH: ${{ inputs.output-path }}
Copy link
Contributor Author

@seanh seanh Oct 4, 2025

Choose a reason for hiding this comment

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

This is exactly the same as the "Archive artifact" step from upload-pages-artifact@v3.0.1 other than INPUT_PATH being renamed to OUTPUT_PATH to match the name used elsewhere in our file.

In v4.0.0 upload-pages-artifact just added --exclude=".[^/]*" to the tar command to exclude hidden files.

Comment on lines +106 to +109
name: github-pages
path: ${{ runner.temp }}/artifact.tar
retention-days: 1
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.

These options are the same as how upload-pages-artifact calls upload-artifact.

@seanh seanh marked this pull request as ready for review October 4, 2025 11:20
@seanh seanh requested a review from Copilot October 4, 2025 11:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR works around a limitation in upload-pages-artifact@v4 that excludes hidden files from GitHub Pages deployments by replacing the action with a custom tar command and direct artifact upload.

  • Removes dependency on upload-pages-artifact@v3 in favor of manual tar creation
  • Adds custom archive step that preserves hidden files while excluding .git and .github directories
  • Updates upload step to use upload-artifact@v4 with specific GitHub Pages configuration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

with:
path: ${{ inputs.output-path }}
name: github-pages
path: ${{ runner.temp }}/artifact.tar
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

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

The path reference uses ${{ runner.temp }} but the tar command creates the file at $RUNNER_TEMP/artifact.tar. GitHub Actions expressions should be consistent - either use ${{ runner.temp }} in both places or $RUNNER_TEMP in both places.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

@seanh seanh Oct 4, 2025

Choose a reason for hiding this comment

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

I'm going to ignore Copilot's suggestion here because I'm following the style of GitHub's own actions (upload-pages-artifact and upload-artifact): for whatever reason they don't use variable references like ${{ runner.temp }} in inline shell scripts within the workflow, but instead use env: to make those variables available to the shell scripts as $RUNNER_TEMP.

seanh added a commit to seanh/ghp-static that referenced this pull request Oct 4, 2025
It prevents hidden files from being deployed. For more details see:
getpelican/pelican#3502
seanh added a commit to seanh/ghp-static that referenced this pull request Oct 4, 2025
It prevents hidden files from being deployed. For more details see:
getpelican/pelican#3502
@justinmayer justinmayer changed the title Don't use upload-pages-artifact Avoid upload-pages-artifact action in GitHub Pages workflow Oct 16, 2025
Copy link
Member

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

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

Many thanks for enhancement and the detailed explanation! ✨

@justinmayer justinmayer merged commit b989441 into main Oct 16, 2025
35 checks passed
@justinmayer justinmayer deleted the remove-upload-pages-artifact branch October 16, 2025 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants