Skip to content

Commit 467d0ae

Browse files
committed
added docs about caching
1 parent 692fc06 commit 467d0ae

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

docs/ce/howto/generate-projects.mdx

+40-1
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,43 @@ generate_projects
6767
root_dir: "staging/"
6868
workflow: default
6969
workflow_file: digger_workflow_staging.yml
70-
```
70+
```
71+
72+
# Caching digger config
73+
74+
In cases where there is a very large terragrunt monorepo and the generation takes alot of time you can
75+
instruct digger to perform caching of the config periodically. Digger will store a cache of the config and you can periodically refresh it from cache to avoid generating on every pull request.
76+
77+
To enable loading cache from pull request you should set this flag:
78+
79+
```
80+
"DIGGER_CONFIG_REPO_CACHE_ENABLED=1"
81+
```
82+
83+
You also need to set the value for "DIGGER_INTERNAL_SECRET" to be a secret that you generate. It will be used for calling the internal endpoint
84+
for refreshing from cache.
85+
86+
The internal url to refresh the cache for a repo and a branch is /_internal/update_repo_cache. It expects some arguments.
87+
Here is a curl request for it as an example"
88+
89+
```
90+
curl -XPOST https://mydigger.app/_internal/update_repo_cache \
91+
-H "Authorization: Bearer $DIGGER_INTERNAL_SECRET" \
92+
-d '{
93+
"repo_full_name": "diggerhq/demo-opentofu",
94+
"branch": "main",
95+
"installation_id": 56497610
96+
}'
97+
```
98+
99+
100+
Where repo_full_name is just a path to the repo
101+
branch is the branch you want to cache from (always this would be your default branch
102+
installation_id is your github installation ID and can be fetched from your github app settings (the place where you installed the app from)
103+
104+
You should get back a response that the caching has been initiated and in the backend logs you will see logs about cloning. You should see an entry for that repo in the repos_cache table if things are successful.
105+
Now you can decide how often you want to refresh the cache and you can then set up a cron task to curl that endpoint for the periods that you want to refresh.
106+
107+
108+
Once it is cached, all future requests will not regenerate projects but instead it will laad it from the cache. In order to force digger to regenerate in a specific pull request you can add the label "digger:no-cache"
109+
to it and if added then all digger plan and digger apply actions on that pr will regenerate the projects.

0 commit comments

Comments
 (0)