Skip to content

Clean branch cache #7348

Clean branch cache

Clean branch cache #7348

Workflow file for this run

name: Clean branch cache
on:
workflow_dispatch :
inputs:
branch:
description: 'Name of the branch for which removing the cache'
required: true
delete:
permissions: read-all
jobs:
clean-cache:
if: inputs.branch || github.event.ref_type == 'branch'
runs-on: ubuntu-latest
permissions:
# Needed to delete cache from action
actions: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Clean Branch Cache
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
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));