Skip to content

Commit

Permalink
update_stats workflow: set up and use actions cache
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffjennings committed Aug 12, 2024
1 parent d2c22d7 commit 743bbab
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/update_stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,29 @@ jobs:
pip install setuptools --upgrade
pip install .
# cache key syntax: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#using-contexts-to-create-cache-keys
- name: Restore cached files
id: cache-files-restore
uses: actions/cache/restore@v4
with:
path: ./cache
key: ${{ runner.os }}-${{ hashFiles('~/.cache_key') }}

- name: Run update script
run: |
python -m repo_stats.runner -a ${{ secrets.ADS_TOKEN }} -g ${{ secrets.GIT_TOKEN }} -c "cache"
# caches are immutable, so create a new one (new key) each time any of the files being cached change.
# the cache key will be new if any files in the cache path have been changed by 'repo_stats.runner'.
# otherwise the cache save will 'fail' (because there's no need to update it - that's fine)
- name: Update cached files
id: cache-files-save
uses: actions/cache/save@v4
with:
path: ./cache
key: ${{ runner.os }}-${{ hashFiles('./cache') }}

- name: Save cache key
run: |
echo ${{ hashFiles('./cache') }} >> ~/.cache_key

0 comments on commit 743bbab

Please sign in to comment.