Skip to content

Commit 925f236

Browse files
feat: implement delete-actions-cache (#1)
1 parent beecf96 commit 925f236

File tree

5 files changed

+141
-0
lines changed

5 files changed

+141
-0
lines changed

.github/release-drafter.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name-template: 'v$RESOLVED_VERSION 🌈'
2+
tag-template: 'v$RESOLVED_VERSION'
3+
categories:
4+
- title: '🚀 Features'
5+
labels:
6+
- 'feat'
7+
- title: '🐛 Bug Fixes'
8+
labels:
9+
- 'fix'
10+
- 'refactor'
11+
- title: '🧰 Maintenance'
12+
labels:
13+
- 'chore'
14+
- title: '📦 dependencies'
15+
labels:
16+
- 'dependencies'
17+
change-template: '- $TITLE (#$NUMBER) by @$AUTHOR'
18+
change-title-escapes: '\<*_&'
19+
autolabeler:
20+
- label: feat
21+
branch:
22+
- '/^feat[/-].+/'
23+
title:
24+
- '/^feat:.+/'
25+
- label: fix
26+
branch:
27+
- '/^fix[/-].+/'
28+
title:
29+
- '/^fix:.+/'
30+
- label: refactor
31+
branch:
32+
- '/^refactor[/-].+/'
33+
title:
34+
- '/^refactor:.+/'
35+
- label: chore
36+
branch:
37+
- '/^chore[/-].+/'
38+
title:
39+
- '/^chore:.+/'
40+
- '/^chore\(deps\):.+/'
41+
- label: dependencies
42+
branch:
43+
- '/^dep(s|endencies)[/-].+/'
44+
- '/^renovate[/-].+/'
45+
title:
46+
- '/chore\(deps\)[/-].+/'
47+
- '/fix\(deps\)[/-].+/'
48+
version-resolver:
49+
major:
50+
labels:
51+
- 'major'
52+
minor:
53+
labels:
54+
- 'minor'
55+
patch:
56+
labels:
57+
- 'patch'
58+
default: patch
59+
template: |
60+
## Changes
61+
62+
$CHANGES

.github/workflows/cache.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Cache
2+
on:
3+
schedule:
4+
- cron: "0 0 * * *"
5+
workflow_dispatch:
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}-cache
8+
cancel-in-progress: true
9+
jobs:
10+
clean:
11+
name: Clean GitHub Actions cache
12+
runs-on: ubuntu-latest
13+
env:
14+
DEBUG: true
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: ./
18+
with:
19+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Release
2+
on:
3+
pull_request:
4+
types: [opened, closed, synchronize]
5+
workflow_dispatch:
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}-release
8+
cancel-in-progress: true
9+
jobs:
10+
draft:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: release-drafter/release-drafter@v5
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# delete-actions-cache
2+
3+
GitHub Actions for delete Actions cache
4+
5+
## Usage
6+
7+
```yaml
8+
name: delete actions cache
9+
on:
10+
push:
11+
branches:
12+
- main
13+
jobs:
14+
clean:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: mokmok-dev/delete-actions-cache@main
19+
with:
20+
github-token: ${{ secrets.GITHUB_TOKEN }}
21+
```
22+
23+
24+
See [action.yml](action.yml) for more details on how to configure it.

action.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "Delete GitHub Actions cache"
2+
description: "Delete GitHub Actions cache"
3+
inputs:
4+
github-token:
5+
description: GitHub token
6+
default: ${{ github.token }}
7+
required: false
8+
outputs:
9+
runs:
10+
using: "composite"
11+
steps:
12+
-
13+
run: |
14+
gh extension install actions/gh-actions-cache
15+
16+
mergedPRNumbers=$(gh pr list --state merged --json number | jq .[].number)
17+
18+
for prNumber in $mergedPRNumbers
19+
do
20+
gh actions-cache list -B refs/pull/$prNumber/merge | cut -f 1 | xargs -I{} gh actions-cache delete --confirm {}
21+
done

0 commit comments

Comments
 (0)