-
Notifications
You must be signed in to change notification settings - Fork 38
35 lines (33 loc) · 1.44 KB
/
clean-cache.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
name: Clean branch cache
on:
workflow_dispatch :
inputs:
branch:
description: 'Name of the branch for which removing the cache'
required: true
delete:
branches:
- '**'
jobs:
clean-cache:
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Clean Branch Cache
if: inputs.branch || github.event.ref_type == 'branch'
uses: actions/github-script@v6
env:
branchName: ${{ inputs.branch || github.event.ref }}
hash: ${{ hashFiles('package.json', 'tsconfig.base.json', 'tsconfig.build.json', 'nx.json') }}
with:
script: |
const globalKey = '${{ runner.os }}-build-' + process.env.hash + '-global-' + process.env.branchName;
const testKey = '${{ runner.os }}-build-' + process.env.hash + '-test-' + process.env.branchName;
const lintKey = '${{ runner.os }}-build-' + process.env.hash + '-lint-' + process.env.branchName;
const [owner, repo] = '${{ github.repository }}'.split('/');
github.rest.actions.deleteActionsCacheByKey({key: globalKey, owner, repo}).catch((e) => console.error(e));
github.rest.actions.deleteActionsCacheByKey({key: testKey, owner, repo}).catch((e) => console.error(e));
github.rest.actions.deleteActionsCacheByKey({key: lintKey, owner, repo}).catch((e) => console.error(e));