Fix cache update for the actions

The caching action doesn't update the cache when cache hit is happenned.
This could be fixed by having unique keys for every cache change and using restore-keys to find these caches.
This commit is contained in:
Ilya Fedin 2022-04-15 11:21:06 +04:00 committed by John Preston
parent 47ec5b18b8
commit fd6d09caaa
2 changed files with 9 additions and 4 deletions

View File

@ -51,6 +51,7 @@ jobs:
env:
UPLOAD_ARTIFACT: "false"
ONLY_CACHE: "false"
PREPARE_PATH: "Telegram/build/prepare/prepare.py"
steps:
- name: Get repository name.
@ -78,14 +79,16 @@ jobs:
uses: actions/cache@v2
with:
path: ThirdParty
key: ${{ runner.OS }}-third-party
key: ${{ runner.OS }}-third-party-${{ hashFiles(format('{0}/{1}', env.REPO_NAME, env.PREPARE_PATH)) }}
restore-keys: ${{ runner.OS }}-third-party-
- name: Libraries cache.
id: cache-libs
uses: actions/cache@v2
with:
path: Libraries
key: ${{ runner.OS }}-libs
key: ${{ runner.OS }}-libs-${{ hashFiles(format('{0}/{1}', env.REPO_NAME, env.PREPARE_PATH)) }}
restore-keys: ${{ runner.OS }}-libs-
- name: Libraries.
run: |

View File

@ -58,7 +58,6 @@ jobs:
defaults:
run:
shell: cmd
working-directory: ${{ github.workspace }}
steps:
- name: Prepare directories.
@ -98,6 +97,8 @@ jobs:
echo "C:\\Program Files\\NASM\\" >> $GITHUB_PATH
echo "C:\\ProgramData\\chocolatey\\lib\\ninja\\tools\\" >> $GITHUB_PATH
echo "CACHE_KEY=$(sha256sum $TBUILD/$REPO_NAME/$PREPARE_PATH | awk '{ print $1 }')" >> $GITHUB_ENV
echo "Configurate git for cherry-picks."
git config --global user.email "you@example.com"
git config --global user.name "Sample"
@ -112,7 +113,8 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.TBUILD }}/Libraries
key: ${{ runner.OS }}-libs
key: ${{ runner.OS }}-libs-${{ env.CACHE_KEY }}
restore-keys: ${{ runner.OS }}-libs-
- name: Libraries.
env: