{"id":20698755,"url":"https://github.com/christian-korneck/delete-run-artifacts-action","last_synced_at":"2025-10-30T01:20:39.911Z","repository":{"id":40726737,"uuid":"246272473","full_name":"christian-korneck/delete-run-artifacts-action","owner":"christian-korneck","description":"github action to delete artifacts at the end of a workflow run","archived":false,"fork":false,"pushed_at":"2023-08-02T14:59:05.000Z","size":515,"stargazers_count":28,"open_issues_count":8,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T15:18:16.138Z","etag":null,"topics":["artifact","artifacts","artifacts-deletion","github","github-actions","github-workflow"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/christian-korneck.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-10T10:33:26.000Z","updated_at":"2024-07-20T18:05:58.000Z","dependencies_parsed_at":"2024-06-19T05:14:13.606Z","dependency_job_id":"ff40b5f0-e150-4e94-9423-267c758a8cf2","html_url":"https://github.com/christian-korneck/delete-run-artifacts-action","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":"0.36363636363636365","last_synced_commit":"4cee595c600e0de644ff62977577be4b4f8811ed"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christian-korneck%2Fdelete-run-artifacts-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christian-korneck%2Fdelete-run-artifacts-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christian-korneck%2Fdelete-run-artifacts-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christian-korneck%2Fdelete-run-artifacts-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christian-korneck","download_url":"https://codeload.github.com/christian-korneck/delete-run-artifacts-action/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250331077,"owners_count":21413093,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artifact","artifacts","artifacts-deletion","github","github-actions","github-workflow"],"created_at":"2024-11-17T00:26:44.718Z","updated_at":"2025-10-10T15:50:24.619Z","avatar_url":"https://github.com/christian-korneck.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"**WARNING: This action deletes data. Use with care and at your own risk.**\n\n![testrun](https://github.com/christian-korneck/delete-run-artifacts-action/workflows/testrun/badge.svg)\n\n# delete-run-artifacts\n\nThis github action deletes all artifacts generated by a github workflow run. It's intended to be used to delete all artifacts generated by a run at the end of this run.\n\nThis can be useful if your workflow temporarily stores artifacts and they're not needed anymore by the end of the run (i.e. because they got uploaded or published as a release by one of the steps). Deleting these redundant artifacts at the end of the run saves storage space (which is limited for private repos).\n\n# How to use\n\nThis action requires a bit more preparation in your repo than most other actions. Because artifacts cannot get deleted during a workflow run (only after a run has completed), we need to spawn a separate workflow run for the deletion by a webhook at the end of the main workflow run.\n\nFirst, create a personal access token (required to call a webhook):\n\n- in your github **user/org** settings: *Settings* -\u003e *Developer Settings* -\u003e *[Personal access tokens](https://github.com/settings/tokens)* -\u003e *[generate new token](https://github.com/settings/tokens/new)*\n  - *Note*: `for webhooks`\n  - *Scope*: `repo` ([docs](https://developer.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/))\n- copy the generated token\n\nthen store the token as a secret in the repo, so that the workflow can use it:\n\n- in your github **repo** settings: *Settings* tab -\u003e *Secrets* -\u003e *add a new secret*\n  - *Name*: `FOR_WEBHOOKS_SECRET`\n  - *Value*: `\u003cYOUR-TOKEN\u003e`\n\nthen create a file in your repo `.github/workflows/webhook_target.yml` with:\n\n```\nname: delete calling job's artifacts\non: repository_dispatch\njobs:\n  main:\n    runs-on: ubuntu-latest\n    steps:\n    - name: Delete artifacts\n      if: github.event.action == 'delete_all_artifacts'\n      uses: christian-korneck/delete-run-artifacts-action@v1\n      env:\n        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n      with:\n        parent_runid: ${{ github.event.client_payload.parent_runid  }}\n        parent_repo: ${{ github.event.client_payload.parent_repo }}\n```\n\nand finally add the following cleanup job to your actual workflow (i.e. in `.github/workflows/workflow.yml`).\nMake sure that `needs:` points to your last job in the workflow, otherwise the cleanup might run too early.\n\n```\nname: your workflow\non: [push]\n  your_last_job:\n    (... add your stuff here ...)\n  cleanup_job:\n    needs: [your_last_job]\n    if: always()\n    runs-on: ubuntu-latest\n    steps:\n    - name: call webhook to delete artifacts\n      env:\n        FOR_WEBHOOKS_SECRET: ${{ secrets.FOR_WEBHOOKS_SECRET }}\n      run: |\n        echo \"::add-mask::$FOR_WEBHOOKS_SECRET\"\n        curl --verbose --fail --show-error --location --request POST \"https://api.github.com/repos/$GITHUB_REPOSITORY/dispatches\" --header \"Authorization: token $FOR_WEBHOOKS_SECRET\" --header 'Content-Type: application/json' --header 'Accept: application/vnd.github.everest-preview+json' --data-raw \"{ \\\"event_type\\\": \\\"delete_all_artifacts\\\", \\\"client_payload\\\": {\\\"parent_runid\\\": \\\"$GITHUB_RUN_ID\\\", \\\"parent_repo\\\": \\\"$GITHUB_REPOSITORY\\\"} }\"\n```\n\nPlease note: Due to a github [limitation](https://github.community/t5/GitHub-Actions/repository-dispatch-not-triggering-actions/m-p/33845#M1677), the file `.github/workflows/webhook_target.yml` needs to be always present in your `master` or default branch. The action will work with any branch however.   \n   \n(Check [this repo](https://github.com/christian-korneck/captive) or the `.github/workflow` dir for a working example)\n\n# Reference\n\nThe action can also be used without a webhook on any past workflow run: \n\n## Inputs\n\n### `parent_repo`\n\n**Required** the github repo that hosts the parent github workflow run. Example: `\"github-user/hello-world\"`.\n\n### `parent_runid`\n\n**Required** the id of the parent github workflow run whos artifacts should get deleted. Example: `\"0000000\"`.\n\n\n## Outputs\n\nnone (just succeeds or fails)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristian-korneck%2Fdelete-run-artifacts-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristian-korneck%2Fdelete-run-artifacts-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristian-korneck%2Fdelete-run-artifacts-action/lists"}