Update cache key

This commit is contained in:
Sidharth Vinod
2024-01-19 15:50:40 +05:30
parent f58a86d747
commit a9a8a208a6

View File

@@ -8,6 +8,9 @@ on:
permissions: permissions:
contents: read contents: read
env:
targetHash: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event_name == 'merge_group' && github.event.merge_group.base.sha || github.event.before }}
jobs: jobs:
cache: cache:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -25,13 +28,13 @@ jobs:
with: with:
save-always: true save-always: true
path: ./cypress/snapshots path: ./cypress/snapshots
key: ${{ runner.os }}-snapshots key: ${{ runner.os }}-snapshots-${{ env.targetHash }}
- name: Switch to base branch - name: Switch to base branch
if: ${{ steps.cache-snapshot.outputs.cache-hit != 'true' }} if: ${{ steps.cache-snapshot.outputs.cache-hit != 'true' }}
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event_name == 'merge_group' && github.event.merge_group.base.sha || 'develop' }} ref: ${{ env.targetHash }}
- name: Cypress run - name: Cypress run
uses: cypress-io/github-action@v4 uses: cypress-io/github-action@v4
@@ -66,7 +69,7 @@ jobs:
uses: actions/cache/restore@v3 uses: actions/cache/restore@v3
with: with:
path: ./cypress/snapshots path: ./cypress/snapshots
key: ${{ runner.os }}-snapshots key: ${{ runner.os }}-snapshots-${{ env.targetHash }}
# Install NPM dependencies, cache them correctly # Install NPM dependencies, cache them correctly
# and run all Cypress tests # and run all Cypress tests
@@ -109,6 +112,14 @@ jobs:
retention-days: 1 retention-days: 1
path: cypress/snapshots/**/__diff_output__/* path: cypress/snapshots/**/__diff_output__/*
- name: Save snapshots cache
id: cache-upload
if: ${{ github.event_name == 'push' }}
uses: actions/cache/save@v3
with:
path: ./cypress/snapshots
key: ${{ runner.os }}-snapshots-${{ github.event.after }}
combineArtifacts: combineArtifacts:
needs: e2e needs: e2e
if: ${{ failure() }} if: ${{ failure() }}