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: env:
UPLOAD_ARTIFACT: "false" UPLOAD_ARTIFACT: "false"
ONLY_CACHE: "false" ONLY_CACHE: "false"
PREPARE_PATH: "Telegram/build/prepare/prepare.py"
steps: steps:
- name: Get repository name. - name: Get repository name.
@ -78,14 +79,16 @@ jobs:
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ThirdParty 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. - name: Libraries cache.
id: cache-libs id: cache-libs
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: Libraries 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. - name: Libraries.
run: | run: |

View file

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