GitHub Actions Artifacts Missing Dotfiles? Use include-hidden-files Safely
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.
Remember 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 current upload-artifact documentation shows @v7; check the action repository when your runner or GitHub Enterprise environment has a different support policy. GitHub Enterprise Server support and artifact version compatibility can differ from GitHub.com.
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?
Use error when the artifact is required for deployment, release, or test results. A warning can be appropriate for an optional diagnostic artifact, but it should be an intentional choice.
References:
actions/upload-artifact hidden-file documentation
actions/upload-artifact repository
Report a typo or broken link, or suggest a related topic.