Files
openipc-builder/.github/workflows/cleanup.yml
T
2febc00893 cleanup: grant actions:write and skip manifest refresh on no-op (#100)
Mirrors OpenIPC/firmware#2133. Today's scheduled cleanup run failed
with HTTP 403: Resource not accessible by integration when dispatching
manifest.yml — the prune job only declared contents:write. The refresh
step also fires on the empty-prune path (exit 0 only exits the step,
not the job), which is wasted work since manifest.yml is already kept
fresh by master.yml's workflow_run.

Add actions:write to the permissions block, and gate the refresh on a
step output so it runs only after an actual deletion.

Co-authored-by: John <zekccsripfwrocp-15689@yn.furvionx.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-01 15:51:11 +03:00

50 lines
1.4 KiB
YAML

name: cleanup
on:
schedule:
- cron: '0 6 * * 1' # Mondays 06:00 UTC (offset by +1h from firmware's cleanup)
workflow_dispatch:
permissions:
contents: write
actions: write
concurrency:
group: gh-pages-manifest
cancel-in-progress: false
jobs:
prune:
name: Prune old nightly releases
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Delete releases beyond the 90 newest
id: prune
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
to_delete=$(gh release list --limit 200 --json tagName,createdAt \
| jq -r '[ .[] | select(.tagName | test("^nightly-[0-9]{8}-[0-9a-f]{7}$")) ]
| sort_by(.createdAt) | reverse | .[90:] | .[].tagName')
if [ -z "$to_delete" ]; then
echo "Nothing to delete; <=90 dated nightlies present."
echo "pruned=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "$to_delete" | while read -r tag; do
[ -z "$tag" ] && continue
echo "Deleting $tag"
gh release delete "$tag" --cleanup-tag --yes
done
echo "pruned=true" >> "$GITHUB_OUTPUT"
- name: Refresh manifest
if: steps.prune.outputs.pruned == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run manifest.yml