How to Overwrite an Existing Artifact in GitHub Actions
v4 artifact names are immutable by default; set overwrite: true to delete and replace an existing one.
Because v4 fails when a name already exists, set overwrite: true on actions/upload-artifact@v4 to remove the prior artifact and upload the new one.
Steps
- Add
overwrite: trueto the upload step. - The action deletes the existing same-named artifact, then uploads.
- Prefer unique names in a matrix; use overwrite for reruns or single-name reports.
Workflow
.github/workflows/ci.yml
steps:
- uses: actions/upload-artifact@v4
with:
name: latest-report
path: report/
overwrite: trueGotchas
- Without
overwrite, a duplicate name fails with "an artifact with this name already exists". - Overwrite is not atomic: a failed rerun can leave you with no artifact briefly.
Related guides
How to Name an Artifact Dynamically in a Matrix in GitHub ActionsGive each matrix leg a unique GitHub Actions artifact name by interpolating matrix values into the name input…
How to Upload a Build Artifact in GitHub ActionsUpload a build output as an artifact in GitHub Actions with actions/upload-artifact@v4, naming it and pointin…