Skip to content

Commit 5ec972f

Browse files
Add: self-hosted-runner-cache-mount (#1593)
1 parent aef2753 commit 5ec972f

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Self-Hosted Runner Cache Mount
2+
3+
- Mount a cache directory on your self-hosted runner
4+
5+
#### Use Case
6+
7+
```yaml
8+
jobs:
9+
cache-mount:
10+
name: Cache mount on self-hosted runner
11+
runs-on: ubuntu-latest
12+
steps:
13+
- ...
14+
- name: Mount Cache
15+
uses: greenbone/actions/self-hosted-runner-cache-mount@v3
16+
- ...
17+
```
18+
## Action Configuration
19+
20+
| Input Variable | Description | Default Value |
21+
| ---------------| ------------------------------------------------------------------------ | --------------------- |
22+
| server | NFS Server IP/Domain to mount. | 10.0.0.1 |
23+
| path | Mount Path on the runner where the cache will be mounted. FULL PATH! | /repository-cache |
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Self-Hosted Runner Cache Mount
2+
description: A GitHub Action to mount a cache directory on your self-hosted runner.
3+
4+
inputs:
5+
server:
6+
description: "NFS Server IP/Domain. Default is 10.0.0.1."
7+
default: "10.0.0.1"
8+
path:
9+
description: "Mount Path(FULL PATH). Default is /repository-cache"
10+
default: "/repository-cache"
11+
12+
branding:
13+
icon: "package"
14+
color: "green"
15+
16+
runs:
17+
using: "composite"
18+
steps:
19+
- name: Mount Cache
20+
shell: bash
21+
run: |
22+
root_path='/var/lib/runner-cache'
23+
sudo apt update
24+
sudo apt install nfs-common -y
25+
sudo mkdir -p "$root_path"
26+
sudo mount -t nfs -o vers=4,sec=sys ${{ inputs.server }}:/ "$root_path"
27+
sudo mkdir -p "$root_path/${{ github.repository }}"
28+
sudo mkdir -p '${{ inputs.path }}'
29+
sudo mount --bind "$root_path/${{ github.repository }}" '${{ inputs.path }}'
30+
sudo umount "$root_path"

0 commit comments

Comments
 (0)