{"id":18310883,"url":"https://github.com/jimschubert/delete-artifacts-action","last_synced_at":"2026-02-13T16:51:20.182Z","repository":{"id":65155544,"uuid":"291336123","full_name":"jimschubert/delete-artifacts-action","owner":"jimschubert","description":"A GitHub Action for deleting artifacts.","archived":false,"fork":false,"pushed_at":"2020-08-29T21:38:08.000Z","size":31,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T08:34:56.816Z","etag":null,"topics":["cleanup","github-actions","hacktoberfest","workflow"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jimschubert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"jimschubert","patreon":"jimschubert"}},"created_at":"2020-08-29T19:30:40.000Z","updated_at":"2023-03-02T10:48:41.000Z","dependencies_parsed_at":"2023-01-05T13:21:09.101Z","dependency_job_id":null,"html_url":"https://github.com/jimschubert/delete-artifacts-action","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"dec11cdb8923cc59d0af088a9b40010a4f674324"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimschubert%2Fdelete-artifacts-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimschubert%2Fdelete-artifacts-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimschubert%2Fdelete-artifacts-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimschubert%2Fdelete-artifacts-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jimschubert","download_url":"https://codeload.github.com/jimschubert/delete-artifacts-action/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247383882,"owners_count":20930365,"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":["cleanup","github-actions","hacktoberfest","workflow"],"created_at":"2024-11-05T16:15:47.657Z","updated_at":"2026-02-13T16:51:20.176Z","avatar_url":"https://github.com/jimschubert.png","language":"Go","funding_links":["https://github.com/sponsors/jimschubert","https://patreon.com/jimschubert"],"categories":[],"sub_categories":[],"readme":"# Delete Artifacts Action\n\nA GitHub Action to help with deleting workflow artifacts.\n\n[![Build Status](https://github.com/jimschubert/delete-artifacts-action/actions/workflows/build.yml/badge.svg)](https://github.com/jimschubert/delete-artifacts-action/actions/workflows/build.yml)\n[![Go Version](https://img.shields.io/github/go-mod/go-version/jimschubert/delete-artifacts-action)](https://github.com/jimschubert/delete-artifacts-action/blob/master/go.mod)\n[![License](https://img.shields.io/github/license/jimschubert/delete-artifacts-action)](https://github.com/jimschubert/delete-artifacts-action/blob/master/LICENSE)\n[![GitHub Release](https://img.shields.io/github/v/release/jimschubert/delete-artifacts-action)](https://github.com/jimschubert/delete-artifacts-action/releases/latest)\n[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-Delete%20Artifacts-blue?logo=github)](https://github.com/marketplace/actions/delete-artifacts)\n\nSee also [jimschubert/delete-artifacts](https://github.com/jimschubert/delete-artifacts).\n\n## Inputs\n\n### `GITHUB_TOKEN`\n\n**Required** Default: `${{github.token}}`\n\nGitHub token used to access the repository defined in the GITHUB_REPOSITORY input.\n\nIt is recommended to [create a new personal access token](https://github.com/settings/tokens/new) with the least permissions (e.g. public_repo).\nUsing a service account for the GitHub Token is also highly recommended.\n\n[Learn more about using secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)\n\n### `GITHUB_REPOSITORY`\n\n**Required** Default: `${{github.repository}}`\n\nThe target github repo in the format owner/repo\n\n### `run_id`\n\n**Optional**\n\nA specific Actions run identifier. You can use this to specify the current run and do some post-run cleanup.\n\n### `min_bytes`\n\n**Required** Default: `\"0\"`\n\nThe minimum file size in bytes. The default is \"0\", effectively meaning it will start off by matching all files.\n\nConsider applying another filter such as name or pattern if you'd like to avoid deleting everything.\n\n**NOTE** This value must be a quoted integer.\n\n### `max_bytes`\n\n**Optional**\n\nThe maximum file size in bytes. If not specified, there is no limit.\n\nThis option is useful if you have many small artifacts and want to keep a specific larger artifact.\n\n**NOTE** This value must be a quoted integer.\n\n### `artifact_name`\n\n**Optional**\n\nThe name of a specific artifact to delete. If not specified, this may result in _all_ artifacts being deleted.\n\n### `pattern`\n\n**Optional**\n\nA POSIX regular expression. This is useful, for example, if you have matrix artifacts with a common prefix or suffix.\n\n\n### `active_duration`\n\n**Optional**\n\nA duration string which defines the duration during which artifacts are considered \"active\" and will therefore not be deleted.\n\nThis setting is useful to avoid deleting artifacts for current or very recent runs (e.g. specify \"10m\"), or to allow\nfor debugging of artifacts for some amount of time (e.g. specify \"23h59m\"). This acts as a retention period for artifacts\nwhen using otherwise aggressive deletion settings.\n\nThis format follows the [go Duration](https://golang.org/pkg/time/#ParseDuration) formatting.\n\n### `log_level`\n\n**Optional**\n\nSpecifies a custom log level.\n\nChoose from these options:\n\n* debug\n* info\n* warn\n* error\n\n### `dry_run`\n\n**Optional** Default: `\"false\"`\n\nPerform a dry-run. It's recommended to do this first to be sure you have correct settings.\n\n## Outputs\n\nThe action itself does not output any arguments.\n\n## Usage\n\n### Create a triggered workflow\n\nArtifacts become associated with a workflow once the workflow completes. You can use a repository dispatch to \"kick off\" an artifact cleanup.\n\n**This step requires a Personal Access Token, rather than the `GITHUB_TOKEN` available by default**\n\nCreate this first file at `.github/workflows/generate.yml`:\n\n```yaml\nname: Generate artifacts and trigger cleanup\non:\n  workflow_dispatch:\n    inputs:\n      size:\n        description: 'Target file size'\n        required: true\n        default: '1M'\n      name:\n        description: 'Artifact name'\n        required: true\n        default: 'artifact.bin'\n\ndefaults:\n  run:\n    shell: bash\n\njobs:\n\n  # This job represents your \"standard\" job. notice that the job outputs `github.run_id` as an example of passing variables to a triggering job\n  generate:\n    runs-on: ubuntu-latest\n    continue-on-error: false\n    outputs:\n      # We can use outputs across jobs in the final trigger job\n      target_run_id: ${{ github.run_id }}\n    steps:\n      # Generate a file of empty bytes (this could be a build task)\n      - name: Generate a file\n        run: |\n          truncate -s ${{ github.event.inputs.size }} ${{ github.event.inputs.name }}\n          echo \"Created file ${{ github.event.inputs.name }} (${{ github.event.inputs.size }})\"\n      # Upload the artifact. Artifacts expire after 90 days, which may count toward storage costs on private repositories\n      - name: Upload artifact as ${{ github.event.inputs.name }}\n        uses: actions/upload-artifact@v6\n        with:\n          name: ${{ github.event.inputs.name }}\n          path: ${{ github.event.inputs.name }}\n\n  # This example triggers via separate job to demonstrate passing variables between jobs and workflows, but the step can exist in a single job. \n  trigger:\n    runs-on: ubuntu-latest\n    needs: generate\n    continue-on-error: false\n    steps:\n      # See https://docs.github.com/en/rest/reference/repos#create-a-repository-dispatch-event\n      # This requires a Personal Access Token (PAT), the GITHUB_TOKEN provided to workflows will not work.\n      - name: Repository Dispatch\n        uses: peter-evans/repository-dispatch@v4\n        with:\n          # THIS MUST BE A PERSONAL ACCESS TOKEN\n          token: ${{secrets.TRIGGER_TOKEN}}\n          repository: ${{github.repository}}\n          event-type: triggered-event\n          # Payload properties can be any name. Note size, base_name, and run_id referring to this workflow's inputs and the generate tasks's outputs\n          client-payload: '{\"ref\": \"${{ github.ref }}\", \"sha\": \"${{ github.sha }}\", \"size\": \"${{ github.event.inputs.size }}\", \"base_name\": \"${{ github.event.inputs.name }}\", \"run_id\": \"${{needs.generate.outputs.target_run_id}}\"}'\n```\n\nCreate the following file at `.github/workflows/cleanup.yml`:\n\n```yaml\nname: Cleanup\non:\n  repository_dispatch:\n    types:\n      - triggered-event\n\njobs:\n\n  # Demonstrate how to delete by name\n  delete-by-name:\n    runs-on: ubuntu-latest\n    continue-on-error: true\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v6\n\n      - name: Delete Artifact by Name\n        uses: jimschubert/delete-artifacts-action@v1\n        with:\n          log_level: 'debug'\n          artifact_name: '${{ github.event.client_payload.base_name }}'\n          min_bytes: '0'\n\n  # Demonstrate how to delete by active_duration\n  delete-by-retention-duration:\n    needs: delete-by-name\n    continue-on-error: true\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v6\n\n      - name: Delete Artifact by active duration (expect no deletions)\n        uses: jimschubert/delete-artifacts-action@v1\n        with:\n          log_level: 'debug'\n          min_bytes: '0'\n          active_duration: '30m'\n\n      - name: Sleep 2 minutes\n        run: |\n          echo \"Sleeping for 2 minutes, then we'll use duration 1m30s\"\n          sleep 120\n\n      - name: Delete Artifact by active duration (expect deletions)\n        uses: jimschubert/delete-artifacts-action@v1\n        with:\n          log_level: 'debug'\n          min_bytes: '0'\n          active_duration: '1m30s'\n\n  # Demonstrates how to use POSIX pattern for deleting artifacts\n  delete-by-pattern:\n    needs: delete-by-retention-duration\n    continue-on-error: true\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v6\n\n      - name: Delete by pattern\n        uses: jimschubert/delete-artifacts-action@v1\n        with:\n          log_level: 'debug'\n          min_bytes: '0'\n          pattern: '\\.pat'\n\n  # Demonstrates how to use a run id for deleting artifacts\n  # This could be used for overall cleanup\n  delete-by-runId:\n    needs: [delete-by-pattern]\n    continue-on-error: true\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v6\n\n      - name: Delete by run id\n        if: ${{ github.event.client_payload.run_id }}\n        uses: jimschubert/delete-artifacts-action@v1\n        with:\n          log_level: 'debug'\n          min_bytes: '0'\n          run_id: '${{ github.event.client_payload.run_id }}'\n```\n\n#### Create a cron workflow\n\nThe following example runs cleanup of _all_ artifacts weekly at a specific time.\n\nIn your repository as `.github/workflows/cleanup.yml`:\n\n```yaml\nname: Weekly cleanup\n\non:\n  schedule:\n    - cron: \"0 18 * * 6\"\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v6\n      - name: Weekly Artifact Cleanup\n        uses: jimschubert/delete-artifacts-action@v1\n        with:\n          log_level: 'error'\n          min_bytes: '0'\n```\n\n## Keeping Actions Updated\n\nIt's highly recommended to use [Dependabot](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot) to keep your GitHub Actions up to date.\n\nCreate `.github/dependabot.yml` in your repository:\n\n```yaml\nversion: 2\nupdates:\n  - package-ecosystem: \"github-actions\"\n    directory: \"/\"\n    schedule:\n      interval: \"weekly\"\n    commit-message:\n      prefix: \"deps\"\n    groups:\n      actions:\n        patterns:\n          - \"*\"\n```\n\nThis configuration:\n- Checks for action updates weekly\n- Groups all action updates into a single PR\n- Uses a `deps` prefix for commits (integrates well with changelog groupings)\n\n## License\n\nThis project is [licensed](./LICENSE) under Apache 2.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimschubert%2Fdelete-artifacts-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjimschubert%2Fdelete-artifacts-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimschubert%2Fdelete-artifacts-action/lists"}