Clean workflow run logs based on configuration.
Please be aware of the Github's API rate limit.
-
token: The token to use to access the GitHub API (optional, default: github.token)
-
owner: The owner of the repository (optional, default: github.repository_owner)
-
repo: The name of the repository (optional, default: github.repository)
-
days_old: The amount of days old to delete (optional, default: 7)(Deprecated) -
runs_older_than: The amount of days for a workflow run, since its last rerun, be considered old (optional, default: 7)
-
runs_to_keep: The amount of latest workflows runs to keep (optional, default: 0)
- result: The number of workflows deleted
This workflow needs write permissions on your actions. Be sure to add the correct permissions as follows:
permissions:
actions: write
jobs:
clean-logs:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: igorjs/gh-actions-clean-workflow@v6
with:
token: ${{ github.token }} # optional
owner: ${{ github.repository_owner }} # optional
repo: ${{ github.repository }} # optional
runs_older_than: 7 # optional
runs_to_keep: 0 # optional
name: Clean Workflow Logs
on:
workflow_dispatch:
inputs:
runs_older_than:
description: "The amount of days old to delete"
default: "7"
required: false
runs_to_keep:
description: "The amount of latest workflows runs to keep"
default: "0"
required: false
jobs:
clean-logs:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: igorjs/gh-actions-clean-workflow@v6
with:
runs_older_than: ${{ github.event.inputs.runs_older_than }} # optional
runs_to_keep: ${{ github.event.inputs.runs_to_keep }} # optional
name: Clean Workflow Logs
on:
schedule:
- cron: "0 0 * * 1" # Runs "At 00:00 on Monday." (see https://crontab.guru)
jobs:
clean-logs:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: igorjs/gh-actions-clean-workflow@v6
with:
runs_older_than: "14" # optional, default value: "7"
runs_to_keep: "20" # optional, default value: "0"
name: Clean Workflow Logs
on:
schedule:
- cron: "0 0 * * 1" # Runs "At 00:00 on Monday." (see https://crontab.guru)
workflow_dispatch:
inputs:
runs_older_than:
description: "The amount of days old to delete"
default: "7"
required: false
env:
SCHEDULED_RUNS_OLDER_THAN: "7"
SCHEDULED_RUNS_TO_KEEP: "20"
jobs:
clean-logs:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: igorjs/gh-actions-clean-workflow@v6
with:
runs_older_than: ${{ github.event.inputs.runs_older_than || env.SCHEDULED_RUNS_OLDER_THAN }}
runs_to_keep: ${{ github.event.inputs.runs_to_keep || env.SCHEDULED_RUNS_TO_KEEP }}