You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The base URL of your cache server. This needs to be accessible by your runners as it is used for making API requests and downloading cached files.
34
44
45
+
#### `CA_KEY_PATH`
46
+
47
+
Path to the CA key. This is used for proxying HTTPS requests which is needed for intercepting cache requests.
48
+
49
+
#### `CA_CERT_PATH`
50
+
51
+
Path to the CA certificate. This is used for proxying HTTPS requests which is needed for intercepting cache requests.
52
+
35
53
#### `STORAGE_DRIVER`
36
54
37
55
- Default: `filesystem`
@@ -60,74 +78,67 @@ variant: subtle
60
78
---
61
79
::
62
80
63
-
#### `CLEANUP_OLDER_THAN_DAYS`
81
+
#### `CACHE_CLEANUP_OLDER_THAN_DAYS`
64
82
65
83
- Default: `90`
66
84
67
85
The number of days to keep stale cache data and metadata before deleting it. Set to `0` to disable cache cleanup.
68
86
69
-
#### `NITRO_PORT`
87
+
#### `CACHE_CLEANUP_CRON`
70
88
71
-
- Default: `3000`
89
+
- Default: `0 0 * * *`
72
90
73
-
The port the server should listen on.
91
+
The cron schedule for running the cache cleanup job.
74
92
75
-
## 2. Setup with Self-Hosted Runners
93
+
#### `UPLOAD_CLEANUP_CRON`
76
94
77
-
To leverage the GitHub Actions Cache Server with your self-hosted runners, you'll need to configure a couple of environment variables on your runners. This ensures that your runners can authenticate with and utilize the cache server effectively.
95
+
- Default: `*/10 * * * *`
78
96
79
-
### Configuring Environment Variables on Self-Hosted Runners
97
+
The cron schedule for running the upload cleanup job. This job will delete any dangling (failed or incomplete) uploads.
80
98
81
-
**`ACTIONS_RESULTS_URL`**: This tells your self-hosted runner where to send cache requests. Set this environment variable to the `API_BASE_URL` of your cache server, making sure to include a trailing slash.
99
+
#### `PROXY_PORT`
82
100
83
-
For example, if your cache server's `API_BASE_URL` is `http://localhost:3000`, you would set `ACTIONS_RESULTS_URL` to `http://localhost:3000/`.
101
+
- Default: `8000`
84
102
85
-
::u-alert
86
-
---
87
-
icon: 'tabler:alert-triangle'
88
-
class: ring-amber-400
89
-
color: amber
90
-
description: Make sure to add a trailing slash to the ACTIONS_RESULTS_URL environment variable.
91
-
variant: subtle
92
-
---
93
-
::
103
+
The port the proxy server should listen on.
94
104
95
-
### Getting the Actions Runner to Use the Cache Server
105
+
#### `NITRO_PORT`
96
106
97
-
The default self-hosted runner overwrites the `ACTIONS_RESULTS_URL` environment variable with the GitHub-hosted cache server URL. To get the runner to use your self-hosted cache server, you'll need to modify the runner binary:
107
+
- Default: `3000`
98
108
99
-
#### Docker
109
+
The port the server should listen on.
100
110
101
-
Just add the following lines to your Dockerfile:
111
+
#### `TEMP_DIR`
102
112
103
-
```dockerfile [Dockerfile]
104
-
FROM ghcr.io/actions/actions-runner:latest
113
+
- Default: os temp dir
105
114
106
-
# modify actions runner binaries to allow custom cache server implementation
107
-
RUN sed -i 's/\x41\x00\x43\x00\x54\x00\x49\x00\x4F\x00\x4E\x00\x53\x00\x5F\x00\x52\x00\x45\x00\x53\x00\x55\x00\x4C\x00\x54\x00\x53\x00\x5F\x00\x55\x00\x52\x00\x4C\x00/\x41\x00\x43\x00\x54\x00\x49\x00\x4F\x00\x4E\x00\x53\x00\x5F\x00\x52\x00\x45\x00\x53\x00\x55\x00\x4C\x00\x54\x00\x53\x00\x5F\x00\x4F\x00\x52\x00\x4C\x00/g' /home/runner/bin/Runner.Worker.dll
108
-
```
115
+
The directory to use for temporary files.
109
116
110
-
#### Bare Metal
117
+
## 2. Setup with Self-Hosted Runners
111
118
112
-
::code-group
119
+
### Generate CA Key and Certificate
113
120
114
-
```bash [Linux]
115
-
sed -i 's/\x41\x00\x43\x00\x54\x00\x49\x00\x4F\x00\x4E\x00\x53\x00\x5F\x00\x52\x00\x45\x00\x53\x00\x55\x00\x4C\x00\x54\x00\x53\x00\x5F\x00\x55\x00\x52\x00\x4C\x00/\x41\x00\x43\x00\x54\x00\x49\x00\x4F\x00\x4E\x00\x53\x00\x5F\x00\x52\x00\x45\x00\x53\x00\x55\x00\x4C\x00\x54\x00\x53\x00\x5F\x00\x4F\x00\x52\x00\x4C\x00/g' /path_to_your_runner/bin/Runner.Worker.dll
RUN echo "<YOUR GENERATED CERTIFICATE>" | sudo tee /usr/local/share/ca-certificates/cache-server-ca.crt
133
+
RUN sudo update-ca-certificates
127
134
128
-
This will replace the strings `ACTIONS_RESULTS_URL` with `ACTIONS_RESULTS_ORL` in the runner binary. This will prevent the runner from overwriting the `ACTIONS_RESULTS_URL` environment variable and allow it to use your self-hosted cache server.
description: Learn how we built the GitHub Actions Cache Server and how it works without any workflow file changes
3
+
description: ''
4
4
---
5
5
6
-
## 1. Reverse-Engineering the cache server
7
-
8
-
This is actually a pretty simple process. We just need to look at the requests that the GitHub Actions runner makes to the cache server and then replicate the api routes. We can use the source code of the official `actions/cache` action to see how the requests are made.
9
-
10
-
GitHub also has very good [documentation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key) on how the cache keys are matched.
11
-
12
-
## 2. Getting the actions runner to use our cache server
13
-
14
-
The whole idea of creating a self-hosted cache server originated from the discovery that the official `actions/cache` action uses an environment variable `ACTIONS_RESULTS_URL` to determine where to send cache requests. This means that we can simply set this environment variable to the base URL of our cache server and the runner will start using it ...right?
15
-
16
-
Well, not exactly. The `actions/cache` action uses the `ACTIONS_RESULTS_URL` environment variable to determine the base URL of the cache server but we cannot overrid this environment variable in any way.
17
-
18
-
The default actions runner always overrides the `ACTIONS_RESULTS_URL` environment variable with an internal URL that points to the official GitHub cache server. This is the code that does it:
The line `Environment["ACTIONS_RESULTS_URL"] = resultsUrl;` is the one that overrides the `ACTIONS_RESULTS_URL` environment variable with the internal URL.
49
-
50
-
To allow overriding the `ACTIONS_RESULTS_URL` environment variable, we need to modify the runner binary. This is a bit tricky because the runner is a compiled binary and we cannot simply modify the source code and recompile it. We need to modify the binary itself. So we did just that. We replaced the string `ACTIONS_RESULTS_URL` with `ACTIONS_RESULTS_ORL` (being careful to keep the same length) in the runner binary. This way, the runner will not override the `ACTIONS_RESULTS_URL` environment variable and we can set it to our cache server's base URL.
6
+
The cache server acts as a proxy for the actions runner. We forward all cache related requests to our cache server implementation and passthrough any non-cache related requests to the original server.
0 commit comments