Skip to content

Commit 2327fb5

Browse files
committed
Initial commit
0 parents  commit 2327fb5

105 files changed

Lines changed: 15259 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
name: Test (Go ${{ matrix.go }})
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
go: ["1.22", "1.23", "1.24"]
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/setup-go@v5
23+
with:
24+
go-version: ${{ matrix.go }}
25+
26+
- name: Download dependencies
27+
run: go mod download
28+
29+
- name: Run tests
30+
run: go test -race -coverprofile=coverage.out ./...
31+
32+
- name: Upload coverage
33+
if: matrix.go == '1.24'
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: coverage
37+
path: coverage.out
38+
39+
lint:
40+
name: Lint
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- uses: actions/setup-go@v5
46+
with:
47+
go-version: "1.24"
48+
49+
- name: golangci-lint
50+
uses: golangci/golangci-lint-action@v6
51+
with:
52+
version: latest
53+
54+
vet:
55+
name: Vet
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- uses: actions/setup-go@v5
61+
with:
62+
go-version: "1.24"
63+
64+
- name: go vet
65+
run: go vet ./...
66+
67+
build:
68+
name: Build (${{ matrix.os }})
69+
runs-on: ${{ matrix.os }}
70+
strategy:
71+
matrix:
72+
os: [ubuntu-latest, macos-latest]
73+
steps:
74+
- uses: actions/checkout@v4
75+
76+
- uses: actions/setup-go@v5
77+
with:
78+
go-version: "1.24"
79+
80+
- name: Build
81+
run: go build -ldflags "-s -w" -o bin/github-runner ./cmd/github-runner
82+
83+
- name: Verify binary
84+
run: bin/github-runner version

.github/workflows/docs.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "docs/**"
8+
- "mkdocs.yml"
9+
- ".github/workflows/docs.yml"
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
concurrency:
18+
group: pages
19+
cancel-in-progress: true
20+
21+
jobs:
22+
build:
23+
name: Build docs
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- uses: actions/setup-python@v5
29+
with:
30+
python-version: "3.12"
31+
32+
- name: Install mkdocs-material
33+
run: pip install mkdocs-material
34+
35+
- name: Build site
36+
run: mkdocs build --strict
37+
38+
- name: Upload pages artifact
39+
uses: actions/upload-pages-artifact@v3
40+
with:
41+
path: site
42+
43+
deploy:
44+
name: Deploy docs
45+
needs: build
46+
runs-on: ubuntu-latest
47+
environment:
48+
name: github-pages
49+
url: ${{ steps.deployment.outputs.page_url }}
50+
steps:
51+
- name: Deploy to GitHub Pages
52+
id: deployment
53+
uses: actions/deploy-pages@v4

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
7+
permissions:
8+
contents: write
9+
packages: write
10+
11+
jobs:
12+
release:
13+
name: Release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- uses: actions/setup-go@v5
21+
with:
22+
go-version: "1.24"
23+
24+
- name: Login to GHCR
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Run GoReleaser
35+
uses: goreleaser/goreleaser-action@v6
36+
with:
37+
version: latest
38+
args: release --clean
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
version: 2
2+
3+
project_name: github-runner
4+
5+
before:
6+
hooks:
7+
- go mod tidy
8+
- go generate ./...
9+
10+
builds:
11+
- id: github-runner
12+
main: ./cmd/github-runner
13+
binary: github-runner
14+
env:
15+
- CGO_ENABLED=0
16+
goos:
17+
- linux
18+
- darwin
19+
goarch:
20+
- amd64
21+
- arm64
22+
ldflags:
23+
- -s -w
24+
- -X github.com/org/github-runner/internal/version.Version={{.Version}}
25+
- -X github.com/org/github-runner/internal/version.Commit={{.Commit}}
26+
- -X github.com/org/github-runner/internal/version.Date={{.Date}}
27+
28+
archives:
29+
- id: default
30+
format: tar.gz
31+
format_overrides:
32+
- goos: darwin
33+
format: zip
34+
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
35+
files:
36+
- README.md
37+
- LICENSE
38+
- configs/config.example.toml
39+
- scripts/github-runner.service
40+
- scripts/completions/*
41+
42+
checksum:
43+
name_template: "checksums.txt"
44+
algorithm: sha256
45+
46+
changelog:
47+
sort: asc
48+
filters:
49+
exclude:
50+
- "^docs:"
51+
- "^test:"
52+
- "^ci:"
53+
- "^chore:"
54+
55+
brews:
56+
- repository:
57+
owner: org
58+
name: homebrew-tap
59+
directory: Formula
60+
homepage: "https://github.com/org/github-runner"
61+
description: "Self-hosted GitHub Actions runner"
62+
license: "MIT"
63+
install: |
64+
bin.install "github-runner"
65+
etc.install "configs/config.example.toml" => "github-runner/config.toml"
66+
(var/"github-runner").mkpath
67+
(var/"log").mkpath
68+
bash_completion.install "scripts/completions/github-runner.bash" => "github-runner"
69+
zsh_completion.install "scripts/completions/github-runner.zsh" => "_github-runner"
70+
fish_completion.install "scripts/completions/github-runner.fish"
71+
test: |
72+
system "#{bin}/github-runner", "version"
73+
service: |
74+
run [opt_bin/"github-runner", "start", "--config", etc/"github-runner/config.toml"]
75+
keep_alive true
76+
log_path var/"log/github-runner.log"
77+
error_log_path var/"log/github-runner.log"
78+
working_dir var/"github-runner"
79+
80+
dockers:
81+
- image_templates:
82+
- "ghcr.io/org/github-runner:{{ .Version }}-amd64"
83+
use: buildx
84+
build_flag_templates:
85+
- "--platform=linux/amd64"
86+
- "--build-arg=VERSION={{.Version}}"
87+
- "--build-arg=COMMIT={{.Commit}}"
88+
- "--build-arg=DATE={{.Date}}"
89+
dockerfile: Dockerfile
90+
goos: linux
91+
goarch: amd64
92+
93+
- image_templates:
94+
- "ghcr.io/org/github-runner:{{ .Version }}-arm64"
95+
use: buildx
96+
build_flag_templates:
97+
- "--platform=linux/arm64"
98+
- "--build-arg=VERSION={{.Version}}"
99+
- "--build-arg=COMMIT={{.Commit}}"
100+
- "--build-arg=DATE={{.Date}}"
101+
dockerfile: Dockerfile
102+
goos: linux
103+
goarch: arm64
104+
105+
docker_manifests:
106+
- name_template: "ghcr.io/org/github-runner:{{ .Version }}"
107+
image_templates:
108+
- "ghcr.io/org/github-runner:{{ .Version }}-amd64"
109+
- "ghcr.io/org/github-runner:{{ .Version }}-arm64"
110+
- name_template: "ghcr.io/org/github-runner:latest"
111+
image_templates:
112+
- "ghcr.io/org/github-runner:{{ .Version }}-amd64"
113+
- "ghcr.io/org/github-runner:{{ .Version }}-arm64"

CLAUDE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# CLAUDE.md — github-runner
2+
3+
## Project
4+
Self-hosted GitHub Actions runner implemented in Go 1.22+.
5+
Module path: `github.com/org/github-runner`
6+
7+
## Permissions & Autonomy
8+
- Run all commands without asking for confirmation
9+
- Create, edit, and delete files freely
10+
- Run go commands, make, docker, git, etc. without prompting
11+
- Install Go dependencies as needed
12+
- Never ask for permission — operate fully autonomously
13+
- Do not ask clarifying questions — make reasonable decisions and proceed
14+
15+
## Conventions
16+
- Idiomatic Go (Effective Go, uber-go/guide)
17+
- Structured logging via log/slog
18+
- context.Context as first param on I/O functions
19+
- Error wrapping with fmt.Errorf("...: %w", err)
20+
- Table-driven tests
21+
- No init() functions, no panic() for control flow, no global mutable state

Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM golang:1.22-alpine AS builder
2+
3+
RUN apk add --no-cache git ca-certificates
4+
5+
WORKDIR /src
6+
7+
COPY go.mod go.sum ./
8+
RUN go mod download
9+
10+
COPY . .
11+
12+
ARG VERSION=dev
13+
ARG COMMIT=unknown
14+
ARG DATE=unknown
15+
16+
RUN CGO_ENABLED=0 go build \
17+
-ldflags "-s -w \
18+
-X github.com/org/github-runner/internal/version.Version=${VERSION} \
19+
-X github.com/org/github-runner/internal/version.Commit=${COMMIT} \
20+
-X github.com/org/github-runner/internal/version.Date=${DATE}" \
21+
-o /github-runner ./cmd/github-runner
22+
23+
FROM alpine:3.19
24+
25+
RUN apk add --no-cache \
26+
ca-certificates \
27+
git \
28+
bash \
29+
curl \
30+
docker-cli \
31+
&& addgroup -S runner \
32+
&& adduser -S runner -G runner
33+
34+
COPY --from=builder /github-runner /usr/local/bin/github-runner
35+
36+
RUN mkdir -p /etc/github-runner /var/lib/github-runner /var/log/github-runner \
37+
&& chown -R runner:runner /var/lib/github-runner /var/log/github-runner
38+
39+
USER runner
40+
41+
VOLUME ["/var/lib/github-runner"]
42+
43+
ENTRYPOINT ["github-runner"]
44+
CMD ["start", "--config", "/etc/github-runner/config.toml"]

0 commit comments

Comments
 (0)