Skip to content

Commit 9461d6c

Browse files
authored
Update configure-self-hosted-runners.md
1 parent c26654b commit 9461d6c

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

learn-pr/github/manage-github-actions-enterprise/includes/configure-self-hosted-runners.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ In the previous unit, you explored how to choose and manage GitHub-hosted and se
55
- Monitoring runner health and performance
66
- Configuring secure access using labels and IP allowlists
77

8-
## Configure Self-Hosted Runners for Enterprise Use
8+
## Configure self-hosted runners for enterprise use
99

1010
Self-hosted runners in GitHub Actions provide greater flexibility and control for enterprises that require **customized environments, network access, and security hardening**. This guide covers best practices for configuring self-hosted runners, including **proxies, labels, and networking** considerations.
1111

12-
### 1. Setting Up a Self-Hosted Runner
12+
### 1. Setting up a self-hosted runner
1313

14-
#### Step 1: Create and Register a Self-Hosted Runner
14+
#### Step 1: Create and register a self-hosted runner
1515
1. Navigate to **GitHub Enterprise → Settings → Actions → Runners**.
1616
2. Click **New Runner** and select the desired OS (**Linux, Windows, or macOS**).
1717
3. Follow the provided commands to install and configure the runner on your machine.
1818

19-
#### Step 2: Install & Start the Runner
19+
#### Step 2: Install & start the runner
2020
Run the following commands based on your OS:
2121

2222
**Linux/macOS**
@@ -31,10 +31,10 @@ Run the following commands based on your OS:
3131
.\run.cmd
3232
```
3333

34-
### 2. Configuring Proxies for Self-Hosted Runners
34+
### 2. Configuring proxies for self-hosted runners
3535
Enterprises often operate behind corporate firewalls and proxies that restrict internet access. To allow self-hosted runners to communicate with GitHub, configure proxy settings as follows:
3636

37-
##### Linux/macOS: Configure Proxy
37+
##### Linux/macOS: Configure proxy
3838
Edit the environment file to define proxy settings:
3939
```
4040
export http_proxy=http://proxy.company.com:8080
@@ -46,29 +46,29 @@ Apply the settings:
4646
```
4747
source ~/.bashrc
4848
```
49-
#### Windows: Configure Proxy
49+
#### Windows: Configure proxy
5050

5151
Use the following PowerShell commands:
5252

5353
```
5454
[System.Environment]::SetEnvironmentVariable("HTTP_PROXY", "http://proxy.company.com:8080", "Machine")
5555
[System.Environment]::SetEnvironmentVariable("HTTPS_PROXY", "http://proxy.company.com:8080", "Machine")
5656
```
57-
### 3.Using Labels for Runner Management
57+
### 3.Using Labels for runner management
5858

5959
Labels help organize and route jobs to specific self-hosted runners based on OS, hardware, or project requirements.
6060

6161
![alt text](image-6.png)
6262

63-
#### Assigning Labels to a Runner
63+
#### Assigning labels to a runner
6464

6565
When configuring a runner, you can assign custom labels:
6666

6767
```
6868
./config.sh --url https://github.com/<org-name> --token <generated-token> --labels "high-memory,gpu"
6969
```
7070

71-
#### Targeting a Specific Runner in a Workflow
71+
#### Targeting a specific runner in a workflow
7272
To run a job on a specific runner with labels, update the workflow .yml:
7373
```
7474
jobs:
@@ -79,7 +79,7 @@ jobs:
7979
uses: actions/checkout@v3
8080
```
8181

82-
### 4.Networking Considerations
82+
### 4.Networking considerations
8383
#### Allowlist GitHub IPs
8484

8585
GitHub-hosted runners operate on dynamic IPs, but self-hosted runners need firewall rules to allow access. Retrieve the latest GitHub IP ranges:
@@ -88,33 +88,33 @@ curl -s https://api.github.com/meta | jq .actions
8888
```
8989
Whitelist these IPs in your firewall settings to ensure connectivity.
9090

91-
#### Private Network & VPN Access
91+
#### Private network & VPN access
9292
For enterprise workloads requiring access to private systems, configure the runner to connect via VPN or an internal network.
9393

94-
### 5. Security Best Practices for Enterprise Runners
94+
### 5. Security best practices for enterprise runners
9595
Restrict runners to trusted workflows: Prevent untrusted code from executing on self-hosted runners.
9696
Use ephemeral runners: Automatically remove runners after jobs to prevent persistent threats.
9797
Monitor runner activity: Log all runner actions and audit access.
9898
Apply OS security patches: Regularly update and secure the runner machine.
9999

100-
### Manage Self-Hosted Runners Using Groups
100+
### Manage self-hosted runners using groups
101101
Runner groups allow organizations to **manage access, control workload distribution, and enforce security policies** for self-hosted runners in GitHub Actions. This guide covers how to **create, manage, and move runners between groups** effectively.
102102

103-
### 1. Understanding Runner Groups
103+
### 1. Understanding runner groups
104104
Runner groups help **organize and control** self-hosted runners within a **GitHub Enterprise or Organization**. They allow:
105105
- Restricting which repositories can use specific runners.
106106
- Controlling runner availability for different teams or workloads.
107107
- Managing permissions for **specific branches, workflows, or environments**.
108108

109-
#### Runner Group Availability
109+
#### Runner group availability
110110
| GitHub Plan | Runner Groups Available? |
111111
|-------------|--------------------------|
112112
| GitHub Free | ❌ Not Available |
113113
| GitHub Pro | ❌ Not Available |
114114
| GitHub Team | ✅ Available |
115115
| GitHub Enterprise | ✅ Available |
116116

117-
### 2. Creating a Runner Group
117+
### 2. Creating a runner group
118118

119119
1. Go to **GitHub → Organization Settings → Actions → Runners**.
120120
2. Click **"New group"** under **Self-Hosted Runners**.
@@ -127,27 +127,27 @@ Runner groups help **organize and control** self-hosted runners within a **GitHu
127127
### 3. Adding Runners to a Group
128128
Once the group is created, you can **add runners manually or during registration**.
129129

130-
##### Option 1: Assign During Registration
130+
##### Option 1: Assign during registration
131131
When configuring a new runner, specify the group:
132132
```sh
133133
./config.sh --url https://github.com/<org-name> --token <generated-token> --runnergroup "Linux-Runners"
134134
```
135-
#### Option 2: Move an Existing Runner
135+
#### Option 2: Move an existing runner
136136
1. Navigate to **GitHub → Organization Settings → Actions → Runners.**
137137
2. Locate the **runner** and click **Edit.**
138138
3. Select a **new runner group** and save changes.
139139

140-
### 4. Managing Access and Permissions
141-
#### Restricting Runner Group Access
140+
### 4. Managing access and permissions
141+
#### Restricting runner group access
142142
**Organization-level runners:** Restrict usage to specific repositories.
143143
**Repository-level runners:** Only selected workflows can access the runner.
144144

145-
Example: Restrict Access to a Specific Repository
145+
Example: Restrict access to a specific repository
146146
1. Navigate to **Runner Group Settings.**
147147
2. Under **Repository Access**, select **"Only select repositories".**
148148
3. Add the repositories that are allowed to use the runner group.
149149

150-
### 5. Moving Runners Between Groups
150+
### 5. Moving runners between groups
151151
To **reassign a runner** from one group to another:
152152

153153
1. Go to **GitHub → Organization Settings → Actions → Runners.**
@@ -166,20 +166,20 @@ Alternatively, unregister and re-register the runner in a different group:
166166
- Regularly audit and update runner groups based on team requirements.
167167
- Monitor runner usage and performance to optimize CI/CD workloads.
168168

169-
## Monitor, Troubleshoot, and Update Self-Hosted Runners**
169+
## Monitor, troubleshoot, and update self-hosted runners**
170170
Managing self-hosted runners effectively requires **continuous monitoring, proactive troubleshooting, and regular updates**. This guide covers best practices and GitHub-recommended methods for ensuring **high availability, security, and performance** of self-hosted runners.
171171

172-
### 1. Monitoring Self-Hosted Runners
172+
### 1. Monitoring self-hosted runners
173173

174-
#### Checking Runner Status
174+
#### Checking runner status
175175
To monitor runner availability:
176176
1. Navigate to **GitHub → Organization Settings → Actions → Runners**.
177177
2. Review the status:
178178
-**Idle** → Ready for workflows.
179179
- 🔄 **Active** → Currently running a job.
180180
-**Offline** → Runner is down or disconnected.
181181

182-
#### Using GitHub API to Fetch Runner Status
182+
#### Using GitHub API to fetch runner status
183183
You can programmatically check the status of self-hosted runners:
184184
```sh
185185
curl -H "Authorization: token <your_github_token>" \
@@ -204,15 +204,15 @@ Response example:
204204
]
205205
}
206206
```
207-
### Logging and Metrics
207+
### Logging and metrics
208208

209209
- **System Logs:** Check logs in the `_diag/` directory within the runner installation folder.
210210
- **GitHub Actions Workflow Logs:** Navigate to Actions → Workflow Run → Logs to see runner execution details.
211211
- **Monitoring via Prometheus/Grafana:** Configure Prometheus exporters to track CPU, memory, and job execution time.
212212

213-
### 2. Troubleshooting Self-Hosted Runners
213+
### 2. Troubleshooting self-hosted runners
214214

215-
#### Common Issues and Fixes
215+
#### Common issues and fixes
216216

217217
| Issue | Possible Cause | Fix |
218218
|------------------------------|---------------------------------------|------------------------------------------|
@@ -221,7 +221,7 @@ Response example:
221221
| Job fails with permission errors | Incorrect runner permissions | Ensure runner has the correct access |
222222
| Workflow execution is slow | High CPU/memory usage | Monitor system metrics & scale runners |
223223

224-
#### Restarting a Runner
224+
#### Restarting a runner
225225
If a runner is stuck or not responding, restart it:
226226

227227
```sh
@@ -232,11 +232,11 @@ For systemd-based Linux runners:
232232
```
233233
sudo systemctl restart actions.runner.<org-name>.<runner-name>.service
234234
```
235-
#### Checking Logs for Errors
235+
#### Checking logs for errors
236236
**Runner logs:** `<runner_dir>/_diag/Runner_<timestamp>.log`
237237
**GitHub Actions logs:** Check workflow execution logs in the GitHub UI.
238238

239-
### 3. Updating Self-Hosted Runners
239+
### 3. Updating self-hosted runners
240240
#### Checking for Runner Updates
241241
GitHub periodically updates runner binaries. To check for updates:
242242

@@ -250,8 +250,8 @@ curl -H "Authorization: token <your_github_token>" \
250250
-H "Accept: application/vnd.github.v3+json" \
251251
https://api.github.com/repos/actions/runner/releases/latest
252252
```
253-
#### Updating the Runner
254-
**1. Manual Update**
253+
#### Updating the runner
254+
**1. Manual update**
255255
Stop the runner
256256
```
257257
./svc.sh stop
@@ -269,7 +269,7 @@ tar xzf ./actions-runner-linux-x64.tar.gz
269269
./svc.sh start
270270
```
271271

272-
#### Automated Updates with GitHub Actions
272+
#### Automated updates with GitHub actions
273273
To automatically check for and update runners:
274274
```
275275
name: Update Runners

0 commit comments

Comments
 (0)