Skip to content

Commit 214e498

Browse files
committed
Add include-hidden-files input
Hidden files and directories (e.g. `.well-known`) are unconditionally excluded from the tar archive. There is no way to include them. (#129) 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. `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. See [expressjs/expressjs.com#2173](expressjs/expressjs.com#2173) for an example of the only sane workaround without this option. Which is to drop this action, manually create the tar, and handing it to `upload-artifact` directly.
1 parent 7b1f4a7 commit 214e498

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

.github/workflows/test-hosted-runners.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,46 @@ jobs:
5757
- name: Check for absence of symlinks
5858
run: if [ $(find artifact2 -type l | wc -l) != 0 ]; then echo "Symlinks found"; exit 1; fi
5959
shell: bash
60+
61+
test-include-hidden:
62+
strategy:
63+
matrix:
64+
os: [ubuntu-latest, windows-latest, macos-latest]
65+
runs-on: ${{ matrix.os }}
66+
67+
steps:
68+
- name: Checkout
69+
uses: actions/checkout@v4
70+
71+
- name: Generate files
72+
run: mkdir artifact && mkdir artifact2 && cd artifact && ../script/new-artifact.sh
73+
shell: bash
74+
75+
- name: Upload Pages artifact
76+
uses: ./
77+
with:
78+
name: pages-artifact-hidden-${{ matrix.os }}
79+
path: artifact
80+
include-hidden-files: true
81+
82+
- name: Download artifact
83+
uses: actions/download-artifact@v4
84+
with:
85+
name: pages-artifact-hidden-${{ matrix.os }}
86+
path: artifact2
87+
88+
- name: Extract artifact
89+
run: tar -xf artifact2/artifact.tar -C artifact2 && rm artifact2/artifact.tar
90+
shell: bash
91+
92+
- name: Check for presence of hidden files
93+
run: if [ $(find artifact2 -regex ".*/\..*" | wc -l) == 0 ]; then echo "Hidden files not found"; exit 1; fi
94+
shell: bash
95+
96+
- name: Compare files
97+
run: diff -qr artifact artifact2
98+
shell: bash
99+
100+
- name: Check for absence of symlinks
101+
run: if [ $(find artifact2 -type l | wc -l) != 0 ]; then echo "Symlinks found"; exit 1; fi
102+
shell: bash

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
| `name` | `false` | `github-pages` | Artifact name |
4949
| `path` | `true` | `_site/` | Path of the directory containing the static assets |
5050
| `retention-days` | `false` | `1` | Duration after which artifact will expire in days |
51+
| `include-hidden-files` | `false` | `false` | Include hidden files and directories (those starting with a dot) in the artifact. Excludes `.git` and `.github` regardless. |
5152

5253
### Outputs 📤
5354

action.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ inputs:
1414
description: "Duration after which artifact will expire in days."
1515
required: false
1616
default: "1"
17+
include-hidden-files:
18+
description: "Include hidden files and directories (those starting with a dot) in the artifact. Excludes .git and .github regardless."
19+
required: false
20+
default: "false"
1721
outputs:
1822
artifact_id:
1923
description: "The ID of the artifact that was uploaded."
@@ -32,7 +36,7 @@ runs:
3236
-cvf "$RUNNER_TEMP/artifact.tar" \
3337
--exclude=.git \
3438
--exclude=.github \
35-
--exclude=".[^/]*" \
39+
${{ inputs.include-hidden-files != 'true' && '--exclude=.[^/]*' || '' }} \
3640
.
3741
echo ::endgroup::
3842
env:
@@ -50,7 +54,7 @@ runs:
5054
-cvf "$RUNNER_TEMP/artifact.tar" \
5155
--exclude=.git \
5256
--exclude=.github \
53-
--exclude=".[^/]*" \
57+
${{ inputs.include-hidden-files != 'true' && '--exclude=.[^/]*' || '' }} \
5458
.
5559
echo ::endgroup::
5660
env:
@@ -68,7 +72,7 @@ runs:
6872
-cvf "$RUNNER_TEMP\artifact.tar" \
6973
--exclude=.git \
7074
--exclude=.github \
71-
--exclude=".[^/]*" \
75+
${{ inputs.include-hidden-files != 'true' && '--exclude=.[^/]*' || '' }} \
7276
--force-local \
7377
"."
7478
echo ::endgroup::

0 commit comments

Comments
 (0)