From 223f58cdbe65109c90b7d903853b8392a9dac494 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 7 Jun 2026 13:53:44 +0000 Subject: [PATCH] Fix Clean Workflow Logs action: replace broken third-party action with gh CLI script The igorjs/gh-actions-clean-workflow@v7 action rejects the GitHub Actions token (${{ github.token }}) due to overly strict token prefix validation, causing every run to fail with: "[Invalid Parameter] must be a valid GitHub token (ghp_, ghs_, or github_pat_)" Replace with a native gh CLI script that uses the pre-installed GitHub CLI on ubuntu-latest runners. The gh CLI handles authentication via GH_TOKEN environment variable without any prefix validation issues. --- .github/workflows/deleteold.yml | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deleteold.yml b/.github/workflows/deleteold.yml index 0e1b8333cb..f2c1cb1f56 100644 --- a/.github/workflows/deleteold.yml +++ b/.github/workflows/deleteold.yml @@ -12,7 +12,28 @@ jobs: clean-logs: runs-on: ubuntu-latest steps: - - uses: igorjs/gh-actions-clean-workflow@v7 - with: - token: ${{ github.token }} - days_old: 90 + - name: Delete old workflow runs + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + run: | + echo "Fetching workflow runs older than 90 days..." + + CUTOFF_DATE=$(date -u -d '90 days ago' '+%Y-%m-%dT%H:%M:%SZ') + + # Get all workflow runs older than 90 days and delete them + PAGE=1 + DELETED=0 + while true; do + RUNS=$(gh api "repos/${REPO}/actions/runs?per_page=100&page=${PAGE}&created=<${CUTOFF_DATE}" --jq '.workflow_runs[].id') + if [ -z "$RUNS" ]; then + break + fi + for RUN_ID in $RUNS; do + echo "Deleting run $RUN_ID" + gh api -X DELETE "repos/${REPO}/actions/runs/${RUN_ID}" && DELETED=$((DELETED + 1)) || echo "Failed to delete run $RUN_ID" + done + PAGE=$((PAGE + 1)) + done + + echo "Done. Deleted $DELETED workflow run(s)."