Bump softprops/action-gh-release from 2.1.0 to 2.2.0 #283
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Delete Caches (PR) | |
on: | |
pull_request_target: | |
types: [closed] | |
workflow_dispatch: | |
inputs: | |
pr-number: | |
description: "Closed PR number" | |
type: string | |
required: true | |
jobs: | |
delete: | |
name: Delete caches | |
runs-on: ubuntu-22.04 | |
permissions: | |
actions: write | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Delete caches | |
run: | | |
ref="refs/pull/${{ github.event.inputs.pr-number || github.event.number }}/merge" | |
sort="last_accessed_at" | |
del_count=0 | |
res=$(gh api --paginate \ | |
-H "Accept: application/vnd.github+json" \ | |
/repos/${{ github.repository }}/actions/caches?sort=$sort) | |
res_count=$(echo "$res" | jq '.actions_caches | length') | |
if [[ "$res_count" -eq 0 ]]; then exit; fi | |
targets=$(echo "$res" | jq \ | |
--arg ref "$ref" \ | |
'.actions_caches[] | select(.ref == $ref) | |
| del(.created_at, .size_in_bytes, .version)') | |
targets_count=$(echo "$targets" | jq -s 'length') | |
if [[ "$targets_count" -eq 0 ]]; then exit; fi | |
echo "Found $targets_count caches" | |
echo "$targets" | |
for id in $(echo "$targets" | jq '.id'); do | |
echo "Delete cache with id: $id ..." | |
gh api \ | |
--method DELETE \ | |
-H "Accept: application/vnd.github+json" \ | |
/repos/${{ github.repository }}/actions/caches/$id | |
(( del_count += 1 )) | |
done | |
echo "Deleted $del_count caches" |