Skip to content

Artifact cleanup deletes all run artifacts (incl. diagnostic/log artifacts); scope to inter-job transfer artifacts #214

Description

@ptr727

Summary

The Delete workflow artifacts job (present in both publish-release.yml and test-pull-request.yml) enumerates and deletes every artifact in the run:

ids=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts --paginate \
  --jq '.artifacts[].id')
for artifact_id in $ids; do
  gh api --method DELETE "repos/${{ github.repository }}/actions/artifacts/$artifact_id"
done

The intent is to remove the temporary inter-job transfer artifacts (e.g. release-asset-<branch>-*, build output) whose durable copies already live on the GitHub release, to stay off the account storage quota.

But selecting .artifacts[].id deletes all artifacts indiscriminately — including any other artifacts a run uploads (diagnostic bundles, build logs / MSBuild binlogs, etc.) that are exactly what you need to debug a failed or surprising run. The blanket delete throws away the debugging trail along with the transfer artifacts.

Proposed fix

Scope the deletion to the artifacts the workflow itself created for transfer, by name pattern, rather than deleting everything:

ids=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts --paginate \
  --jq '.artifacts[] | select(.name | test("^release-asset-")) | .id')

(Extend the test(...) alternation to whatever transfer-artifact name prefixes the build uses.) Anything not matching the transfer-artifact naming — diagnostics, logs, future artifacts — is then retained.

Apply to both publish-release.yml and test-pull-request.yml (identical pattern).

Note

Run logs proper are governed by Actions log retention and are not touched by the artifacts API; this issue is specifically about logs/diagnostics uploaded as artifacts, which the blanket delete removes as collateral. Scoping the delete preserves them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions