-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (39 loc) · 1.44 KB
/
main-workflow.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
name: Main push
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}/${{ github.head_ref || github.ref_name || github.ref }}
cancel-in-progress: true
jobs:
cache-cleanup:
if: ${{ always() }}
needs: test
runs-on: ubuntu-latest
permissions:
# `actions:write` permission is required to delete caches
# See also: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id
actions: write
contents: read
defaults:
# run:
# working-directory: backend
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting bundle caches..."
gh actions-cache delete ${{ runner.os }}-gems-v3-${{ hashFiles('./backend/Gemfile.lock') }} -R $REPO -B $BRANCH_NAME --confirm
echo "Deleting asset caches..."
gh actions-cache delete ${{ runner.os }}-assets-cache-${{ hashFiles('./backend/app/assets/**', './backend/vendor/assets/**', '!.git') }} -R $REPO -B $BRANCH_NAME --confirm
echo "Done"
env:
GH_TOKEN: ${{ secrets.TOKEN }}