-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete artifacts uploaded by actions/upload-artifact@v4
#24
Conversation
|
run: | | ||
echo "Hello GitHub Actions" | ||
export GH_REPO="${{ github.repository }}" | ||
gh api \ | ||
--method DELETE \ | ||
/repos/{owner}/{repo}/actions/artifacts/"$EXTRA_ID" | ||
env: | ||
EXTRA_ID: ${{ needs.upload.outputs.extra-id }} | ||
GH_TOKEN: ${{ github.token }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Artifact IDs can be passed to downstream step through
- upstream step output
artifact-id
set byactions/upload-artifact@v4
- upstream job output
<output_name>: ${{ steps.<step_id>.outputs.artifact-id }}
- (optional) downstream job (step) env
<env_var>: ${{ needs.<upstream_job_id>.outputs.<output_name> }}
Job outputs are available to all downstream jobs that depend on this job.
https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs
Till now, two successful ways to delete artifact(s) uploaded by The common part is that an artifact is deleted through gh api --method DELETE /repos/OWNER/REPO/actions/artifacts/ARTIFACT_ID see API doc https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28#delete-an-artifact. What's different is how artifact id is fetched:
|
Other possibilities
|
octokit.rest.actions.listWorkflowRunArtifacts({
owner,
repo,
run_id,
});
octokit.rest.actions.deleteArtifact({
owner,
repo,
artifact_id,
}); |
e5e31bd
to
0c1c973
Compare
390e0b9
to
33c6154
Compare
Supported by https://github.com/GeekyEggo/delete-artifact/releases/tag/v4.0.0 |
The ideal solution is that
|
https://github.blog/changelog/2023-12-14-github-actions-artifacts-v4-is-now-generally-available/
https://github.com/actions/toolkit/tree/main/packages/artifact