https://github.com/zwave-js/turborepo-cache
Self-hosted Turborepo cache based on Cloudflare KV
https://github.com/zwave-js/turborepo-cache
Last synced: over 1 year ago
JSON representation
Self-hosted Turborepo cache based on Cloudflare KV
- Host: GitHub
- URL: https://github.com/zwave-js/turborepo-cache
- Owner: zwave-js
- License: mit
- Created: 2022-09-11T19:55:52.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-04T16:42:03.000Z (over 3 years ago)
- Last Synced: 2025-01-10T18:19:57.061Z (over 1 year ago)
- Language: JavaScript
- Size: 1.15 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# turborepo-cache
Self-hosted remote Turborepo cache for Cloudflare Workers.
## Usage
1. Set up a Cloudflare account
1. Clone this repo
1. Create a Github Actions Secret `CLOUDFLARE_ACCOUNT_ID` and set it to your Cloudflare account ID
1. Create an access token in Cloudflare and store it as the Github Actions Secret `CLOUDFLARE_API_TOKEN`
1. Run `yarn`
1. Run `yarn wrangler login` to authenticate
1. Run `yarn wrangler kv:namespace create "TURBO_CACHE"` to create a KV namespace, and replace this line in `wrangler.toml`
```toml
{ binding = "TURBO_CACHE", id = "fe734ad580ec407f9fec0aeba92d0407" }
```
with what the previous command tells you to.
1. Generate a secret value to authenticate your requests. You can use this command for example:
```
node -p 'require("crypto").randomBytes(32).toString("hex")'
```
1. Store this value as a secret in your Cloudflare Account:
```
wrangler secret put SECRET_TOKEN
```
and paste it when asked to.
1. Store the same value as an Github Actions secret `TURBO_CACHE_TOKEN` in the repo you want to use Turborepo Remote Caching in.
1. Store the address of your worker as another secret `TURBO_CACHE_SERVER` in the same repo.
1. Configure an env variable in your workflows:
```yml
env:
TURBO_FLAGS: "--api=${{ secrets.TURBO_CACHE_SERVER }} --token=${{ secrets.TURBO_CACHE_TOKEN }} --team="
```
and append it to every command that uses Turborepo, e.g.
```yml
- name: Compile TypeScript code
run: yarn build $TURBO_FLAGS
```