init to git
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
# GitHub Action Runners (Docker Compose)
|
||||
|
||||
Self-hosted GitHub Actions runners running in Docker, based on
|
||||
[myoung34/docker-github-actions-runner](https://github.com/myoung34/docker-github-actions-runner).
|
||||
|
||||
## Quick start
|
||||
|
||||
### 1. Create the data folder for your org
|
||||
|
||||
Each runner stores its work directory under `data/<your-org-name>`:
|
||||
|
||||
```bash
|
||||
mkdir -p data/myorg
|
||||
```
|
||||
|
||||
### 2. Get a GitHub access token
|
||||
|
||||
1. Go to **[https://github.com/settings/tokens**]() (on your **user** account, not the org).
|
||||
2. Click **Generate new token (classic)**.
|
||||
3. **Name:** something like `github-self-hosted-runners`.
|
||||
4. **Expiration:** set to **No expiration**.
|
||||
5. Check these scopes:
|
||||
- `admin:org`
|
||||
- `admin:org_hook`
|
||||
- `notifications`
|
||||
- `read:public_key`
|
||||
- `read:repo_hook`
|
||||
- `repo`
|
||||
- `workflow`
|
||||
6. Generate and copy the token (it looks like `ghp_XXXXXXXXXXXXXXXXXXXXXXXXXX`).
|
||||
|
||||
### 3. Configure `docker-compose.yml`
|
||||
|
||||
Edit the service and set your values:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
github-runner-myorg:
|
||||
image: git.neo24.net/public/github-action-runner:latest
|
||||
#image: myoung34/github-runner:latest
|
||||
restart: unless-stopped
|
||||
container_name: github-runner-myorg
|
||||
privileged: true
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- ./data/myorg:/home/runner/work
|
||||
environment:
|
||||
DOCKER_HOST: unix:///var/run/docker.sock
|
||||
RUNNER_NAME: ghr-myorg
|
||||
RUNNER_SCOPE: org
|
||||
ORG_NAME: myorg
|
||||
LABELS: self-hosted,linux,docker,x64
|
||||
RUNNER_WORKDIR: /home/runner/work
|
||||
ACCESS_TOKEN: ghp_XXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
```
|
||||
|
||||
Replace `myorg` with your org name and paste your token into `ACCESS_TOKEN`.
|
||||
|
||||
### 4. Start the runner
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Check it's connected under **GitHub → Org → Settings → Actions → Runners**, then 💥 you're done.
|
||||
|
||||
## 5. Put the runner in a group
|
||||
|
||||
Once the runner shows up, group it so you can control which repos can use it.
|
||||
|
||||
### Create the group
|
||||
|
||||
1. Go to **https://github.com/organizations/myorg/settings/actions/runner-groups**.
|
||||
2. Create a new group named `self-hosted`.
|
||||
3. **Repository access:** select **Selected repositories**.
|
||||
4. Check **Allow public repositories**
|
||||
5. **Workflow access:** select **All workflows**.
|
||||
|
||||
### Move the runner into the group
|
||||
|
||||
1. Go to **https://github.com/organizations/myorg/settings/actions/runners**.
|
||||
2. Find your new runner and click it.
|
||||
3. In the **Runner group** section, move it into `self-hosted`
|
||||
|
||||
### Assign repositories to the group
|
||||
|
||||
Go back to **https://github.com/organizations/myorg/settings/actions/runner-groups**,
|
||||
open the `self-hosted` group, and use the **Selected repositories** ⚙️ (cog) button to
|
||||
add the repositories that are allowed to use this runner.
|
||||
|
||||
> Replace `myorg` in the URLs above with your actual org name.
|
||||
|
||||
## Useful commands
|
||||
|
||||
```bash
|
||||
docker compose logs -f # follow logs
|
||||
docker compose down # stop and remove
|
||||
docker compose pull # update the image
|
||||
```
|
||||
|
||||
## Adding more runners
|
||||
|
||||
Copy the service block, rename it (e.g. `github-runner-otherorg`), give it a unique
|
||||
`container_name` / `RUNNER_NAME`, point its volume at a new `data/<org>` folder, and
|
||||
create that folder with `mkdir -p data/<org>`.
|
||||
|
||||
## Notes
|
||||
|
||||
- The default image is mirrored to `git.neo24.net/public/github-action-runner:latest`.
|
||||
To re-mirror the upstream image (see `cmd-to-push.txt`):
|
||||
|
||||
```bash
|
||||
docker buildx imagetools create \
|
||||
--tag git.neo24.net/public/github-action-runner:latest \
|
||||
myoung34/github-runner:latest
|
||||
```
|
||||
|
||||
- Keep your `ACCESS_TOKEN` secret — don't commit it to a public repo.
|
||||
Reference in New Issue
Block a user