GitHub Actions Artifacts: Fix Missing Files and Dotfiles
If a GitHub Actions artifact contains dist/app.js but not dist/.well-known/, .lighthouseci/, or another dot-prefixed path, the uploader may be behaving as designed. actions/upload-artifact excludes hidden files and directories by default. Set include-hidden-files: true only after narrowing the upload path and checking that the staging directory contains no credentials.
The safe fix is therefore two parts: explicitly opt in to hidden files, and explicitly exclude sensitive files. Turning the option on for the entire repository can upload .env, .git, signing material, or tool state that was never meant to leave the runner.
Confirm what exists before uploading
First inspect the directory that the workflow intends to publish. This checks the filesystem without printing file contents:
- name: Inspect artifact staging shell: bash run: | set -euo pipefail test -d dist find dist -print | sortIf the expected path is absent here, the problem is in the build or staging step, not the artifact action. If the path exists and begins with ., the default hidden-file filter is the likely cause.
Separate hidden files from an empty match
include-hidden-files and if-no-files-found control different boundaries. Use the staging listing to decide which one needs attention:
| Filesystem result | What the action sees | Safer decision |
|---|---|---|
| The required path is absent | No matching files | Fix the build or path, and keep if-no-files-found: error for required output. |
| Only dot-prefixed files or directories are present | The default filter removes the matches | Use a narrow path with include-hidden-files: true, then exclude secrets. |
| Non-hidden files exist, but the action finds nothing | The glob or working directory is wrong | Check pwd, use an explicit path, and inspect the resolved staging directory. |
| No output is expected for this run | No matching files is intentional | Choose warn or ignore explicitly instead of hiding a required-output failure. |
The upstream action metadata sets include-hidden-files to false and if-no-files-found to warn by default. Verify a required hidden entry before uploading without printing its contents:
- name: Verify required artifact entries shell: bash run: | set -euo pipefail test -f dist/.well-known/assetlinks.json find dist -type f -print | sortRemember that “hidden” here means a dot-prefixed file or directory. A file marked hidden by an operating-system attribute but named report.json is not the same case. The action’s official README documents this behavior and the opt-in input.
Upload a narrow directory with an explicit exclusion
For a build that needs a hidden .well-known directory, upload only the build output and exclude environment files:
- name: Upload website artifact uses: actions/upload-artifact@v7 with: name: website path: | dist/ !dist/.env !dist/**/.env include-hidden-files: true if-no-files-found: errorThe negative patterns are a second line of defense, not a replacement for staging hygiene. Add exclusions for the secret formats your build can generate, then review the final path list in CI logs. If your artifact needs only one hidden path, an even narrower staging directory is easier to audit than enabling hidden-file upload across all of dist.
if-no-files-found: error changes a missing output from a warning into a failed job. That is usually the right choice for release bundles, deployment packages, and test reports: a green workflow should not silently publish an empty or incomplete artifact.
Stage only the files that belong in the artifact
When a tool writes hidden state beside the desired output, copy the intended files to a clean directory before uploading:
- name: Prepare release bundle shell: bash run: | set -euo pipefail rm -rf artifact-staging mkdir -p artifact-staging/.well-known cp -R dist/assets artifact-staging/assets cp dist/.well-known/assetlinks.json artifact-staging/.well-known/
- name: Upload release bundle uses: actions/upload-artifact@v7 with: name: release-bundle path: artifact-staging/ include-hidden-files: true if-no-files-found: errorThe staging pattern makes the upload contract visible in the workflow. It also limits the blast radius if a future build tool starts creating a new dotfile under dist.
Do not print secret values while debugging. find is useful for names and paths, but a recursive cat, an environment dump, or an unfiltered archive listing can expose credentials in public workflow logs. Review the action permissions and retention policy as part of the artifact design.
Check the action and repository boundary
Use the major version supported by your repository. The upstream README currently uses @v7 in its examples, while its GHES note says upload-artifact@v4+ is not supported there and lists v3.2.2 or v3.2.2-node20 for GitHub Enterprise Server. Check the action repository when your runner or enterprise environment has a different support policy.
Artifacts are for files produced by a workflow, not for passing an arbitrary working tree between jobs. Give each job a clear output directory and a unique artifact name. When a later job consumes the bundle, validate the expected hidden path after download instead of assuming that a successful upload means every file was present.
For a related workflow input issue, see the guide to boolean workflow_dispatch inputs. The same principle applies here: verify the value at the boundary where GitHub interprets it, rather than trusting a superficially successful run.
FAQ
Why does upload-artifact skip my .bin or .lighthouseci directory?
Both are dot-prefixed paths, so hidden files are excluded by default. Confirm that the build created the directory, then use include-hidden-files: true with a narrow and reviewed upload path.
Is include-hidden-files: true dangerous?
It can be. Hidden directories frequently contain credentials, local state, or tokens. Stage only the required files and exclude known secret paths before enabling the option.
Should if-no-files-found be error?
warn is the upstream default. Use error when the artifact is required for deployment, release, or test results. ignore or a warning can be appropriate for an optional diagnostic artifact, but it should be an intentional choice.
References:
actions/upload-artifact action inputs
Report a typo or broken link, or suggest a related topic.