Skip to content

Commit

Permalink
Update delete-old-releases.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
decyjphr authored Aug 20, 2024
1 parent 1e95bcf commit 891ad18
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/delete-old-releases.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
name: Delete old releases
permissions: write-all

on:
workflow_dispatch:
inputs:
startDate:
type: text
beforeDate:
type: string
required: true
description: enter the date in YYYY-mm-dd format
description: YYYY-MM-DD - All releases before this date are deleted.
default: "2024-01-01"

jobs:
delete-releases:
runs-on: ubuntu-latest
steps:
- run: |
# for i in $(gh release list --repo https://github.com/github/safe-settings --json createdAt,tagName --limit 1000 --jq '.[] | select(.createdAt < ${{ inputs.startDate }} ) | .tagName'); do gh release delete --repo https://github.com/github/safe-settings $i --cleanup-tag -y; done
gh release list --repo https://github.com/github/safe-settings --json createdAt,tagName --limit 1000 --jq '.[] | select(.createdAt < ${{ inputs.startDate }} ) | .tagName'
- name: Delete releases
run: |
for i in $(gh release list --repo https://github.com/$GITHUB_REPOSITORY --json createdAt,tagName --limit 1000 | jq --arg date $BEFORE_DATE '.[] | select(.createdAt < $date ) | .tagName' | tr -d '"'); do echo $i ; gh release delete $i -y --cleanup-tag --repo https://github.com/$GITHUB_REPOSITORY ; done
echo Deleted releases before $BEFORE_DATE in https://github.com/$GITHUB_REPOSITORY >> $GITHUB_STEP_SUMMARY
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BEFORE_DATE: ${{ inputs.beforeDate }}


0 comments on commit 891ad18

Please sign in to comment.