mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Cleanup pip cache workaround [ci] (#82272)
This commit is contained in:
parent
a07117470e
commit
e3749e0f76
56
.github/workflows/cache.yml
vendored
56
.github/workflows/cache.yml
vendored
@ -1,56 +0,0 @@
|
|||||||
name: Delete Caches
|
|
||||||
|
|
||||||
# yamllint disable-line rule:truthy
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [closed]
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
pr-number:
|
|
||||||
description: "Closed PR number"
|
|
||||||
type: string
|
|
||||||
required: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
delete:
|
|
||||||
name: "Delete unused caches (PR #${{ github.event.inputs.pr-number || github.event.number }})"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
actions: write
|
|
||||||
steps:
|
|
||||||
- name: Delete caches
|
|
||||||
run: |
|
|
||||||
ref="refs/pull/${{ github.event.inputs.pr-number || github.event.number }}/merge"
|
|
||||||
|
|
||||||
page=1
|
|
||||||
per_page=100
|
|
||||||
del_count=0
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
res=$(curl -fsS \
|
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
-H "Authorization: token ${{ github.token }}" \
|
|
||||||
"https://api.github.com/repos/${{ github.repository }}/actions/caches?per_page=$per_page&page=$page")
|
|
||||||
|
|
||||||
res_count=$(echo $res | jq '.actions_caches | length')
|
|
||||||
if [ $res_count -eq 0 ]; then break; fi
|
|
||||||
|
|
||||||
targets=$(echo $res | jq \
|
|
||||||
--arg ref "$ref" \
|
|
||||||
'.actions_caches[] | select(.ref == $ref) | del(.created_at, .size_in_bytes, .version)')
|
|
||||||
echo "$targets"
|
|
||||||
|
|
||||||
for id in $(echo $targets | jq '.id'); do
|
|
||||||
curl -sS \
|
|
||||||
-X DELETE \
|
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
-H "Authorization: token ${{ github.token }}" \
|
|
||||||
"https://api.github.com/repos/${{ github.repository }}/actions/caches/$id"
|
|
||||||
((del_count+=1))
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ $res_count -lt $per_page ]; then break; fi
|
|
||||||
((page+=1))
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Delete $del_count caches."
|
|
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
@ -558,6 +558,10 @@ jobs:
|
|||||||
- base
|
- base
|
||||||
permissions:
|
permissions:
|
||||||
actions: write
|
actions: write
|
||||||
|
# Limit to 'dev' branch until permissions issue is resolved
|
||||||
|
# https://github.com/home-assistant/core/pull/80898
|
||||||
|
# https://github.com/home-assistant/core/pull/82254
|
||||||
|
if: github.ref == 'refs/heads/dev'
|
||||||
steps:
|
steps:
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
run: |
|
run: |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user