-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (53 loc) · 1.91 KB
/
regenerate-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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Regenerate cache
on:
schedule:
# Daily
- cron: '23 4 * * *'
jobs:
regenerate-cache:
permissions:
actions: write
runs-on: ubuntu-latest
steps:
- name: Delete prior caches
run: |
gh extension install actions/gh-actions-cache
echo "Fetching prior cache keys"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting prior caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: ${{ github.ref }}
# Caches and restores the bazelisk download directory, the bazel build directory.
- name: Cache bazel
uses: actions/cache@v4
env:
cache-name: bazel-cache
with:
path: |
~/.cache/bazelisk
~/.cache/bazel
~/.cache/bazel-repo
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}-${{ github.sha }}
# Pull caches from:
# - The current sha,
# - The current branch,
# - base branch
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}-${{ github.sha }}
${{ runner.os }}-${{ env.cache-name }}-${{ github.ref }}-
${{ runner.os }}-${{ env.cache-name }}-refs/heads/${{ github.base_ref }}-
- name: Checkout
uses: actions/checkout@v4
- name: Bazel clean
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc clean --expunge
- name: bazel test //...
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...