Compare commits

..

5 Commits

Author SHA1 Message Date
Bishal Prasad
43a06bb470 Merge branch 'main' into bishal/readme-cache-version 2022-11-07 13:22:12 +05:30
Bishal Prasad
91db8faf67 Use ubuntu/squid instead of datadog/squid 2022-11-07 10:29:43 +05:30
Bishal Prasad
18c7ce934f Merge branch 'main' into bishal/readme-cache-version 2022-11-04 11:09:21 +05:30
Bishal Prasad
f38dc63de9 Update README.md
Co-authored-by: Sankalp Kotewar <98868223+kotewar@users.noreply.github.com>
2022-11-04 11:08:32 +05:30
Bishal Prasad
7498c77912 Add more details to version section in readme 2022-10-19 19:15:40 +05:30

View File

@@ -118,7 +118,7 @@ See [Examples](examples.md) for a list of `actions/cache` implementations for us
A cache key can include any of the contexts, functions, literals, and operators supported by GitHub Actions.
For example, using the [`hashFiles`](https://docs.github.com/en/actions/learn-github-actions/expressions#hashfiles) function allows you to create a new cache when dependencies change.
For example, using the [`hashFiles`](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#hashfiles) function allows you to create a new cache when dependencies change.
```yaml
- uses: actions/cache@v3
@@ -230,43 +230,6 @@ jobs:
```
</details>
## Deleting caches
We can not re-use caches from pull request branches in other branches like main, such caches can eat up the storage quota and hence causing thrashing on more useful branches like main. In order to resolve this issue, we can use [gh-actions-cache cli](https://github.com/actions/gh-actions-cache/) to delete caches. This workflow uses `gh-actions-cache` to delete all the caches created by all the pull requests.
```
name: cleanup-caches
on:
workflow_dispatch
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
echo "Fetching list of cache key"
## This will extract out all the cache keys for pull requests
cacheKeysForPR=$(gh actions-cache list -R $REPO | grep "refs/pull" | cut -d $'\t' -f 1 )
## Setting this to not fail the workflow while deleting duplicate cache keys. We can have same cache key for multiple branches based on the cache key generation.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
## Known practices and workarounds
Following are some of the known practices/workarounds which community has used to fulfill specific requirements. You may choose to use them if suits your use case. Note these are not necessarily the only or the recommended solution.