Skip to content

Remove old nightly releases #991

Remove old nightly releases

Remove old nightly releases #991

Workflow file for this run

# Removes old nightly releases
name: Remove old nightly releases
on:
workflow_dispatch: # for testing changes to this workflow
# Run nightly at 0500 UTC.
schedule:
- cron: '0 5 * * *'
jobs:
remove-old-releases:
name: Remove old nightly releases
runs-on: ubuntu-latest
steps:
- name: Remove all but last 90 releases
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
shell: bash
run: |
# The GitHub API returns results in reverse chronological order, so `[90:]` captures the
# 91st and older releases which we want to delete.
RELEASES_TO_DELETE=`gh api --paginate repos/dsp-testing/codeql-cli-nightlies/releases --jq 'map(select(.prerelease == true)).[90:].[] | .tag_name'`
echo "$RELEASES_TO_DELETE" | awk NF | tr '\n' '\0' | xargs --no-run-if-empty -0 -n1 gh release delete --repo dsp-testing/codeql-cli-nightlies --yes
echo "$RELEASES_TO_DELETE" | awk NF | sed 's/^/\/repos\/dsp-testing\/codeql-cli-nightlies\/git\/refs\/tags\//' | tr '\n' '\0' | xargs --no-run-if-empty -0 -n1 gh api -X DELETE --silent