Files
upload-pages-artifact/action.yml
Jon Church f7615f5917 Add include-hidden-files input
# The Problem

Hidden files and directories (e.g. `.well-known`) are unconditionally excluded from the tar archive. There is no way to include them. (#129)

# The Solution

Add an `include-hidden-files` input (default `false`) that skips the `--exclude=.[^/]*` pattern when set to `true`. `.git` and `.github` are always excluded regardless. Test coverage added for the new option.

I think this is the right approach rather than #134. Keep the default behavior safe, and give a sane option to users who know what they're doing. It was safe enough for upload-artifact, it should be safe enough here.

# Context

`actions/upload-artifact` introduced hidden file exclusion and a corresponding `include-hidden-files` option in [v4.4.0](https://github.com/actions/upload-artifact/releases/tag/v4.4.0). This action adopted the same exclusion behavior in its tar step but never added the equivalent option. This PR closes that gap.

The only sane workaround without this option is to drop this action, manually create the tar, and hand it to `upload-artifact` directly. See [expressjs/expressjs.com#2173](https://github.com/expressjs/expressjs.com/pull/2173) for an example.
2026-01-30 14:03:56 -05:00

90 lines
2.8 KiB
YAML

name: "Upload GitHub Pages artifact"
description: "A composite action that prepares your static assets to be deployed to GitHub Pages"
author: "GitHub"
inputs:
name:
description: 'Artifact name'
required: false
default: 'github-pages'
path:
description: "Path of the directory containing the static assets."
required: true
default: "_site/"
retention-days:
description: "Duration after which artifact will expire in days."
required: false
default: "1"
include-hidden-files:
description: "Include hidden files and directories (those starting with a dot) in the artifact. Excludes .git and .github regardless."
required: false
default: "false"
outputs:
artifact_id:
description: "The ID of the artifact that was uploaded."
value: ${{ steps.upload-artifact.outputs.artifact-id }}
runs:
using: composite
steps:
- name: Archive artifact
shell: sh
if: runner.os == 'Linux'
run: |
echo ::group::Archive artifact
tar \
--dereference --hard-dereference \
--directory "$INPUT_PATH" \
-cvf "$RUNNER_TEMP/artifact.tar" \
--exclude=.git \
--exclude=.github \
${{ inputs.include-hidden-files != 'true' && '--exclude=.[^/]*' || '' }} \
.
echo ::endgroup::
env:
INPUT_PATH: ${{ inputs.path }}
# Switch to gtar (GNU tar instead of bsdtar which is the default in the MacOS runners so we can use --hard-dereference)
- 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" \
--exclude=.git \
--exclude=.github \
${{ inputs.include-hidden-files != 'true' && '--exclude=.[^/]*' || '' }} \
.
echo ::endgroup::
env:
INPUT_PATH: ${{ inputs.path }}
# Massage the paths for Windows only
- name: Archive artifact
shell: bash
if: runner.os == 'Windows'
run: |
echo ::group::Archive artifact
tar \
--dereference --hard-dereference \
--directory "$INPUT_PATH" \
-cvf "$RUNNER_TEMP\artifact.tar" \
--exclude=.git \
--exclude=.github \
${{ inputs.include-hidden-files != 'true' && '--exclude=.[^/]*' || '' }} \
--force-local \
"."
echo ::endgroup::
env:
INPUT_PATH: ${{ inputs.path }}
- name: Upload artifact
id: upload-artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ inputs.name }}
path: ${{ runner.temp }}/artifact.tar
retention-days: ${{ inputs.retention-days }}
if-no-files-found: error