Skip to content

Commit dceaba2

Browse files
authored
Merge pull request #39242 from github/repo-sync
Repo sync
2 parents a6d669b + f7b1aa4 commit dceaba2

File tree

27 files changed

+383
-189
lines changed

27 files changed

+383
-189
lines changed

.github/actions/retry-command/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ inputs:
77
max_attempts:
88
description: 'Maximum number of retry attempts'
99
required: false
10-
default: '8'
10+
default: '12'
1111
delay:
1212
description: 'Delay between attempts in seconds'
1313
required: false
14-
default: '15'
14+
default: '30'
1515

1616
runs:
1717
using: 'composite'
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: Dependency caching
3+
shortTitle: Dependency caching
4+
intro: 'Learn about dependency caching for workflow speed and efficiency.'
5+
versions:
6+
fpt: '*'
7+
ghes: '*'
8+
ghec: '*'
9+
type: overview
10+
topics:
11+
- Workflows
12+
---
13+
14+
## About workflow dependency caching
15+
16+
Workflow runs often reuse the same outputs or downloaded dependencies from one run to another. For example, package and dependency management tools such as Maven, Gradle, npm, and Yarn keep a local cache of downloaded dependencies.
17+
18+
{% ifversion fpt or ghec %} Jobs on {% data variables.product.prodname_dotcom %}-hosted runners start in a clean runner image and must download dependencies each time, causing increased network utilization, longer runtime, and increased cost. {% endif %}To help speed up the time it takes to recreate files like dependencies, {% data variables.product.prodname_dotcom %} can cache files you frequently use in workflows.
19+
20+
{%- ifversion fpt or ghec %}
21+
22+
> [!NOTE]
23+
> When using self-hosted runners, caches from workflow runs are stored on {% data variables.product.company_short %}-owned cloud storage. A customer-owned storage solution is only available with {% data variables.product.prodname_ghe_server %}.
24+
25+
{%- endif %}
26+
27+
{% data reusables.actions.comparing-artifacts-caching %}
28+
29+
For more information on workflow run artifacts, see [AUTOTITLE](/actions/using-workflows/storing-workflow-data-as-artifacts).
30+
31+
## Next steps
32+
33+
To implement dependency caching in your workflows, see [AUTOTITLE](/actions/reference/dependency-caching-reference).

content/actions/concepts/workflows-and-actions/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ children:
1313
- /about-custom-actions
1414
- /contexts
1515
- /expressions
16+
- /dependency-caching
1617
- /about-monitoring-workflows
1718
- /notifications-for-workflow-runs
1819
- /about-troubleshooting-workflows

content/actions/how-tos/managing-workflow-runs-and-deployments/managing-workflow-runs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ children:
1515
- /deleting-a-workflow-run
1616
- /downloading-workflow-artifacts
1717
- /removing-workflow-artifacts
18+
- /manage-caches
1819
- /approving-workflow-runs-from-public-forks
1920
- /approving-workflow-runs-from-private-forks
2021
redirect_from:
2122
- /actions/managing-workflow-runs-and-deployments/managing-workflow-runs
2223
---
23-
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
title: Managing caches
3+
intro: 'You can monitor, filter, and delete dependency caches created from your workflows.'
4+
versions:
5+
fpt: '*'
6+
ghes: '*'
7+
ghec: '*'
8+
shortTitle: Manage caches
9+
allowTitleToDifferFromFilename: true
10+
---
11+
12+
This article describes managing caches with the {% data variables.product.prodname_dotcom %} web interface, but you can also manage them:
13+
14+
* Using the REST API. See [AUTOTITLE](/rest/actions/cache).
15+
* With the `gh cache` subcommand from the command line. See the [GitHub CLI documentation](https://cli.github.com/manual/gh_cache).
16+
17+
## Viewing cache entries
18+
19+
You can use the web interface to view a list of cache entries for a repository. In the cache list, you can see how much disk space each cache is using, when the cache was created, and when the cache was last used.
20+
21+
{% data reusables.repositories.navigate-to-repo %}
22+
{% data reusables.repositories.actions-tab %}
23+
{% data reusables.repositories.actions-cache-list %}
24+
1. Review the list of cache entries for the repository.
25+
26+
* To search for cache entries used for a specific branch, click the **Branch** dropdown menu and select a branch. The cache list will display all of the caches used for the selected branch.
27+
* To search for cache entries with a specific cache key, use the syntax `key: key-name` in the **Filter caches** field. The cache list will display caches from all branches where the key was used.
28+
29+
![Screenshot of the list of cache entries.](/assets/images/help/repository/actions-cache-entry-list.png)
30+
31+
## Deleting cache entries
32+
33+
Users with `write` access to a repository can use the {% data variables.product.prodname_dotcom %} web interface to delete cache entries.
34+
35+
{% data reusables.repositories.navigate-to-repo %}
36+
{% data reusables.repositories.actions-tab %}
37+
{% data reusables.repositories.actions-cache-list %}
38+
1. To the right of the cache entry you want to delete, click {% octicon "trash" aria-label="Delete cache" %}.
39+
40+
![Screenshot of the list of cache entries. A trash can icon, used to delete a cache, is highlighted with a dark orange outline.](/assets/images/help/repository/actions-cache-delete.png)
41+
42+
## Force deleting cache entries
43+
44+
Caches have branch scope restrictions in place, which means some caches have limited usage options. For more information on cache scope restrictions, see [AUTOTITLE](/actions/reference/dependency-caching-reference#restrictions-for-accessing-a-cache). If caches limited to a specific branch are using a lot of storage quota, it may cause caches from the `default` branch to be created and deleted at a high frequency.
45+
46+
For example, a repository could have many new pull requests opened, each with their own caches that are restricted to that branch. These caches could take up the majority of the cache storage for that repository. {% data reusables.actions.cache-eviction-policy %} In order to prevent cache thrashing when this happens, you can set up workflows to delete caches on a faster cadence than the cache eviction policy will. You can use the {% data variables.product.prodname_cli %} to delete caches for specific branches.
47+
48+
The following example workflow uses `gh cache` to delete up to 100 caches created by a branch once a pull request is closed.
49+
50+
To run the following example on cross-repository pull requests or pull requests from forks, you can trigger the workflow with the `pull_request_target` event. If you do use `pull_request_target` to trigger the workflow, there are security considerations to keep in mind. For more information, see [AUTOTITLE](/actions/using-workflows/events-that-trigger-workflows#pull_request_target).
51+
52+
```yaml
53+
name: Cleanup github runner caches on closed pull requests
54+
on:
55+
pull_request:
56+
types:
57+
- closed
58+
59+
jobs:
60+
cleanup:
61+
runs-on: ubuntu-latest
62+
permissions:
63+
actions: write
64+
steps:
65+
- name: Cleanup
66+
run: |
67+
echo "Fetching list of cache keys"
68+
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
69+
70+
## Setting this to not fail the workflow while deleting cache keys.
71+
set +e
72+
echo "Deleting caches..."
73+
for cacheKey in $cacheKeysForPR
74+
do
75+
gh cache delete $cacheKey
76+
done
77+
echo "Done"
78+
env:
79+
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
80+
GH_REPO: {% raw %}${{ github.repository }}{% endraw %}
81+
BRANCH: refs/pull/{% raw %}${{ github.event.pull_request.number }}{% endraw %}/merge
82+
```
83+
84+
Alternatively, you can use the API to automatically list or delete all caches on your own cadence. For more information, see [AUTOTITLE](/rest/actions/cache#about-the-cache-in-github-actions).

content/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,5 @@ children:
2121
- /using-environments-for-deployment
2222
- /control-the-concurrency-of-workflows-and-jobs
2323
- /running-variations-of-jobs-in-a-workflow
24-
- /caching-dependencies-to-speed-up-workflows
2524
- /storing-and-sharing-data-from-a-workflow
2625
---

0 commit comments

Comments
 (0)