Skip to content

Commit 04e8258

Browse files
authored
Merge pull request #2 from vaggeliskls/feat/enable-token
Feat/enable token
2 parents ceeac44 + 85f9ba3 commit 04e8258

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

.env

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Runners settings
2-
# ex. org: https://github.com/<org name>/staging-monorepo or repo: https://github.com/<org name>/<repo name>
3-
PAT=<Replace with your personal access token>
2+
PAT=<TOKEN>
3+
# -- OR --
4+
# TOKEN=<TOKEN>
5+
# ex. RUNNER_URL org: https://github.com/<org name> or repo: https://github.com/<org name>/<repo name>
46
RUNNER_URL=<org url or repo url>
57
RUNNERS=2
68
# Vagrant image settings

README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,41 @@ Explore an innovative, efficient, and cost-effective approach to deploying a cus
99
- [docker](https://www.docker.com/) version 24 or higher.
1010
- [docker-compose](https://www.docker.com/) version 1.18 or higher.
1111

12-
<!-- # 🚥 PAT - Organization Github Personal Access token
13-
1. -->
12+
# 🚥 Authentication for Self-Hosted Runners
13+
For the purpose of authenticating your custom self-hosted runners, we offer two viable authentication methods:
14+
15+
1. Personal Access Token (`PAT`) - The Personal Access Token is a static, manually created token that provides secure access to GitHub. This offers a long-lived method of authentication (The PAT token needs Read and Write access to organization self-hosted runners).
16+
17+
2. Registration Token (`TOKEN`) - The Registration Token is a dynamic, short-lived token generated automatically by GitHub during the creation of a new self-hosted runner. This provides a temporary but immediate method of authentication.
18+
19+
> **Note:** Only one of these authentication methods is necessary. Choose the method that best fits your
1420
1521
# 🚀 Deployment Guide
1622

1723
1. Create/Update the environmental file `.env`
1824
- `PAT`: Personal access token from GitHub
25+
- `TOKEN`: Short lived Github token
1926
- `RUNNER_URL`: The URL of the GitHub that the runner connects to
2027
- `RUNNERS`: Number of runners
2128
- `MEMORY`: Amount of memory for the Vagrant image (in MB)
2229
- `CPU`: Number of CPUs for the Vagrant image
2330
- `DISK_SIZE`: Disk size for the Vagrant image (in GB)
31+
32+
### Example with PAT
2433
```env
2534
# Runner settings
26-
PAT=<Replace with your personal access token>
35+
PAT=<Your Personal access token>
36+
RUNNER_URL=<runner url>
37+
RUNNERS=1
38+
# Vagrant image settings
39+
MEMORY=8000 # 8GB
40+
CPU=4
41+
DISK_SIZE=100
42+
```
43+
### Example with TOKEN
44+
```env
45+
# Runner settings
46+
TOKEN=<Your short lived acess token>
2747
RUNNER_URL=<runner url>
2848
RUNNERS=1
2949
# Vagrant image settings
@@ -47,9 +67,6 @@ services:
4767
```
4868
3. Run: `docker-compose up -d`
4969

50-
> The PAT token needs Read and Write access to organization self-hosted runners
51-
52-
5370
# 🌐 Access via Remote Desktop
5471
For debugging purposes or testing you can always connect to the VM with remote desktop softwares.
5572

Vagrantfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ Vagrant.configure("2") do |config|
4343
Write-Host "Running $runner";
4444
$random = -join ((48..57) + (97..122) | Get-Random -Count 8 | % {[char]$_});
4545
Expand-Archive -LiteralPath ${GITHUB_RUNNER_FILE} -DestinationPath runner-$random -Force;
46-
Invoke-Expression -Command "C:\\runner-$random\\config.cmd --name ${GITHUB_RUNNER_NAME}_$random --replace --unattended --url ${RUNNER_URL} --labels ${GITHUB_RUNNER_LABELS} --pat ${PAT}";
46+
if (![string]::IsNullOrEmpty("${PAT}")) {
47+
Invoke-Expression -Command "C:\\runner-$random\\config.cmd --name ${GITHUB_RUNNER_NAME}_$random --replace --unattended --url ${RUNNER_URL} --labels ${GITHUB_RUNNER_LABELS} --pat ${PAT}";
48+
} else {
49+
Invoke-Expression -Command "C:\\runner-$random\\config.cmd --name ${GITHUB_RUNNER_NAME}_$random --replace --unattended --url ${RUNNER_URL} --labels ${GITHUB_RUNNER_LABELS} --token ${TOKEN}";
50+
}
4751
Start-Process "C:\\runner-$random\\run.cmd" -Credential ($credentials);
4852
}
4953
SHELL

startup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export RANDOM_STR=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n
88
if [ ! -f Vagrantfile ]
99
then
1010
envsubst \
11-
'${VAGRANT_BOX},${PRIVILEGED},${INTERACTIVE},${MEMORY},${CPU},${DISK_SIZE},${GITHUB_RUNNER_FILE},${GITHUB_RUNNER_NAME},${RANDOM_STR},${RUNNERS},${GITHUB_RUNNER_LABELS},${RUNNER_URL},${PAT},${GITHUB_RUNNER_URL}' \
11+
'${VAGRANT_BOX},${PRIVILEGED},${INTERACTIVE},${MEMORY},${CPU},${DISK_SIZE},${GITHUB_RUNNER_FILE},${GITHUB_RUNNER_NAME},${RANDOM_STR},${RUNNERS},${GITHUB_RUNNER_LABELS},${RUNNER_URL},${PAT},${TOKEN},${GITHUB_RUNNER_URL}' \
1212
< Vagrantfile.tmp > Vagrantfile
1313
fi
1414

0 commit comments

Comments
 (0)