Skip to content

Commit

Permalink
allow build cache to auto invalidate with new commits
Browse files Browse the repository at this point in the history
  • Loading branch information
parvit committed Apr 5, 2024
1 parent e4dc7bd commit 5addd81
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/common-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
runs-on: vm-client
env:
GH_TOKEN: ${{ github.token }}
CACHE_KEY: qpep-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
steps:
- name: Install the github cli
uses: sersoft-gmbh/setup-gh-cli-action@v2
Expand All @@ -75,20 +76,23 @@ jobs:
if: ${{ inputs.ignore_caches }}
run: |
gh version
gh cache delete qpep-${{ github.head_ref || github.ref_name }}
gh cache delete ${{ env.CACHE_KEY }}
- name: Restore cached build
if: ${{ ! inputs.ignore_caches }}
id: cache-build
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/build
key: qpep-${{ github.head_ref || github.ref_name }}
key: ${{ env.CACHE_KEY }}

- name: Cleanup
if: ${{ inputs.ignore_caches || steps.cache-build.outputs.cache-hit != 'true' }}
shell: powershell
run: rm ${{ github.workspace }}\* -r -force
run: |
rm ${{ github.workspace }}\* -r -force
$old_id = gh cache list --json id,key -q ".[]|select(.key | startswith(\"qpep-\"))|.id"
gh cache delete $old_id
- uses: actions/checkout@v4
if: ${{ inputs.ignore_caches || steps.cache-build.outputs.cache-hit != 'true' }}
Expand Down Expand Up @@ -149,7 +153,7 @@ jobs:
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}/build
key: qpep-${{ github.head_ref || github.ref_name }}
key: ${{ env.CACHE_KEY }}

- name: Auto-cancel workflow on error
if: failure()
Expand Down

0 comments on commit 5addd81

Please sign in to comment.