Skip to content

Commit

Permalink
added docs about caching
Browse files Browse the repository at this point in the history
  • Loading branch information
motatoes committed Nov 15, 2024
1 parent 692fc06 commit 467d0ae
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion docs/ce/howto/generate-projects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,43 @@ generate_projects
root_dir: "staging/"
workflow: default
workflow_file: digger_workflow_staging.yml
```
```

# Caching digger config

In cases where there is a very large terragrunt monorepo and the generation takes alot of time you can
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.

To enable loading cache from pull request you should set this flag:

```
"DIGGER_CONFIG_REPO_CACHE_ENABLED=1"
```

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
for refreshing from cache.

The internal url to refresh the cache for a repo and a branch is /_internal/update_repo_cache. It expects some arguments.
Here is a curl request for it as an example"

```
curl -XPOST https://mydigger.app/_internal/update_repo_cache \
-H "Authorization: Bearer $DIGGER_INTERNAL_SECRET" \
-d '{
"repo_full_name": "diggerhq/demo-opentofu",
"branch": "main",
"installation_id": 56497610
}'
```


Where repo_full_name is just a path to the repo
branch is the branch you want to cache from (always this would be your default branch
installation_id is your github installation ID and can be fetched from your github app settings (the place where you installed the app from)

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.
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.


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"
to it and if added then all digger plan and digger apply actions on that pr will regenerate the projects.

0 comments on commit 467d0ae

Please sign in to comment.