Skip to content

Commit e2806d9

Browse files
committed
init commit
1 parent 9b92a9f commit e2806d9

File tree

6 files changed

+112
-0
lines changed

6 files changed

+112
-0
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: rustunit

.github/workflows/cd.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: cd
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
8+
jobs:
9+
build_runner:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
attestations: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Log in to the Container registry
18+
uses: docker/login-action@v3
19+
with:
20+
registry: ghcr.io
21+
username: ${{ github.actor }}
22+
password: ${{ secrets.GITHUB_TOKEN }}
23+
- uses: extractions/setup-just@v1
24+
- name: Docker build
25+
run: |
26+
cd runner
27+
just build
28+
- name: Docker Push
29+
run: |
30+
cd runner
31+
just push

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
# github-runner
22
Our custom docker image used for self hosted gh runners
3+
4+
It requires you to have setup a github PAT with these scopes:
5+
* `repo`
6+
* `admin:org`
7+
8+
This runner is build to be used on an organizational level, you need to provide these two `env` vars:
9+
10+
```
11+
$ORGANIZATION
12+
$ACCESS_TOKEN
13+
```

dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM ghcr.io/actions/actions-runner:2.320.0
2+
3+
USER root
4+
5+
# Update and upgrade the system
6+
RUN apt-get update -y && apt-get upgrade -y
7+
8+
# Install necessary packages
9+
RUN apt-get install -y --no-install-recommends \
10+
curl \
11+
wget \
12+
build-essential \
13+
libssl-dev \
14+
libffi-dev \
15+
jq \
16+
sudo \
17+
libasound2-dev \
18+
libudev-dev \
19+
unzip \
20+
pkg-config \
21+
apt-transport-https \
22+
ca-certificates && \
23+
rm -rf /var/lib/apt/lists/*
24+
25+
# Copy the start script and make it executable
26+
COPY start.sh /start.sh
27+
RUN chmod +x /start.sh
28+
29+
USER runner
30+
31+
# Define the entrypoint
32+
ENTRYPOINT ["/start.sh"]

justfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
IMAGE_NAME:="ghcr.io/rustunit/github-runner"
3+
IMAGE_TAG:="0.1.0"
4+
5+
build:
6+
docker build -t {{IMAGE_NAME}}:latest .
7+
docker build -t {{IMAGE_NAME}}:{{IMAGE_TAG}} .
8+
9+
push:
10+
docker push {{IMAGE_NAME}}
11+
docker push {{IMAGE_NAME}}:{{IMAGE_TAG}}

start.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
ORGANIZATION=$ORGANIZATION
4+
ACCESS_TOKEN=$ACCESS_TOKEN
5+
6+
echo "Get Reg-Token for ${ORGANIZATION} and '${ORGANIZATION}'"
7+
8+
REG_TOKEN=$(curl -sX POST -H "Authorization: token ${ACCESS_TOKEN}" https://api.github.com/orgs/${ORGANIZATION}/actions/runners/registration-token | jq .token --raw-output)
9+
10+
cd /home/docker/actions-runner
11+
12+
echo "Config..."
13+
14+
./config.sh --url https://github.com/${ORGANIZATION} --token ${REG_TOKEN}
15+
16+
cleanup() {
17+
echo "Removing runner..."
18+
./config.sh remove --unattended --token ${REG_TOKEN}
19+
}
20+
21+
trap 'cleanup; exit 130' INT
22+
trap 'cleanup; exit 143' TERM
23+
24+
echo "Run..."
25+
26+
./run.sh & wait $!

0 commit comments

Comments
 (0)