Skip to content

Commit f6278fa

Browse files
committed
Add support for run in organization
1 parent fb91019 commit f6278fa

File tree

5 files changed

+442
-427
lines changed

5 files changed

+442
-427
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,10 @@ Use the following steps to prepare your workflow for running on your EC2 self-ho
156156
157157
**2. Prepare GitHub personal access token**
158158

159-
1. Create a new GitHub personal access token with the `repo` scope.
160-
The action will use the token for self-hosted runners management in the GitHub account on the repository level.
159+
1. Create a fine-grained personal access token with the required permissions:
160+
- **Repository-level runners (default):** Repository permissions: Administration (read/write), Contents (read)
161+
- **Organization-level runners:** Organization permissions: Self-hosted runners (read/write)
162+
Repository permissions: Contents (read)
161163
2. Add the token to GitHub secrets.
162164

163165
**3. Prepare EC2 image**
@@ -205,7 +207,7 @@ Now you're ready to go!
205207
|               Name               | Required | Description |
206208
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
207209
| `mode` | Always required. | Specify here which mode you want to use: <br> - `start` - to start a new runner; <br> - `stop` - to stop the previously created runner. |
208-
| `github-token` | Always required. | GitHub Personal Access Token with the `repo` scope assigned. |
210+
| `github-token` | Always required. | Fine-grained GitHub Personal Access Token with appropriate permissions (see setup instructions above). |
209211
| `ec2-image-id` | Required if you use the `start` mode. | EC2 Image Id (AMI). <br><br> The new runner will be launched from this image. <br><br> The action is compatible with Amazon Linux 2 images. |
210212
| `ec2-instance-type` | Required if you use the `start` mode. | EC2 Instance Type. |
211213
| `subnet-id` | Required if you use the `start` mode. | VPC Subnet Id. <br><br> The subnet should belong to the same VPC as the specified security group. |
@@ -224,6 +226,7 @@ Now you're ready to go!
224226
| `ec2-volume-size` | Optional | Defines the size of the EC2 Volume in GB, will use the AWS default of 8 GB if not provided. |
225227
| `ec2-device-name` | Optional | Defines the device name used for the root volume. |
226228
| `ec2-volume-type` | Optional | Defines the device type used for the root volume. |
229+
| `run-runner-in-org` | Optional | Default: false. When set to true, the runner will be registered at the organization level instead of the repository level. This allows using fine-grained personal access tokens with only the "Self-hosted runners" organization permission and "Contents" repository permission, avoiding the need for repository admin permissions. |
227230

228231
### Environment variables
229232

@@ -270,6 +273,8 @@ jobs:
270273
with:
271274
mode: start
272275
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
276+
# Optional: Use organization-level runner for enhanced security
277+
# run-runner-in-org: true
273278
ec2-image-id: ami-123
274279
ec2-instance-type: t3.nano
275280
subnet-id: subnet-123
@@ -310,6 +315,8 @@ jobs:
310315
with:
311316
mode: stop
312317
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
318+
# Optional: Use organization-level runner for enhanced security
319+
# run-runner-in-org: true
313320
label: ${{ needs.start-runner.outputs.label }}
314321
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}
315322
```

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ inputs:
112112
description: >-
113113
Specify user under whom the runner service should run
114114
required: false
115+
run-runner-in-org:
116+
description: >-
117+
Runner is run in repo by default, but can also be run under the org
118+
required: false
115119
ec2-volume-size:
116120
description: >-
117121
EC2 volume size in GB.

0 commit comments

Comments
 (0)