File tree Expand file tree Collapse file tree 3 files changed +102
-0
lines changed
github/actions/self-hosted-runner Expand file tree Collapse file tree 3 files changed +102
-0
lines changed Original file line number Diff line number Diff line change
1
+ FROM debian:buster
2
+
3
+ ARG RUNNER_VERSION="2.169.1"
4
+
5
+ ENV GITHUB_PERSONAL_TOKEN ""
6
+ ENV GITHUB_OWNER ""
7
+ ENV GITHUB_REPOSITORY ""
8
+
9
+ RUN apt-get update \
10
+ && apt-get install -y \
11
+ curl \
12
+ sudo \
13
+ git \
14
+ jq \
15
+ tar \
16
+ gnupg2 \
17
+ apt-transport-https \
18
+ ca-certificates \
19
+ && apt-get clean \
20
+ && rm -rf /var/lib/apt/lists/*
21
+
22
+ RUN useradd -m github && \
23
+ usermod -aG sudo github && \
24
+ echo "%sudo ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
25
+
26
+ #setup docker runner
27
+ RUN curl -sSL https://get.docker.com/ | sh
28
+ RUN usermod -aG docker github
29
+
30
+ USER github
31
+ WORKDIR /home/github
32
+
33
+ RUN curl -O -L https://github.com/actions/runner/releases/download/v$RUNNER_VERSION/actions-runner-linux-x64-$RUNNER_VERSION.tar.gz
34
+ RUN tar xzf ./actions-runner-linux-x64-$RUNNER_VERSION.tar.gz
35
+ RUN sudo ./bin/installdependencies.sh
36
+
37
+ COPY --chown=github:github entrypoint.sh ./entrypoint.sh
38
+ RUN sudo chmod u+x ./entrypoint.sh
39
+
40
+ ENTRYPOINT ["/home/github/entrypoint.sh"]
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ registration_url=" https://api.github.com/repos/${GITHUB_OWNER} /${GITHUB_REPOSITORY} /actions/runners/registration-token"
3
+ echo " Requesting registration URL at '${registration_url} '"
4
+
5
+ payload=$( curl -sX POST -H " Authorization: token ${GITHUB_PAT} " ${registration_url} )
6
+ export RUNNER_TOKEN=$( echo $payload | jq .token --raw-output)
7
+
8
+ ./config.sh \
9
+ --name $( hostname) \
10
+ --token ${RUNNER_TOKEN} \
11
+ --url https://github.com/${GITHUB_OWNER} /${GITHUB_REPOSITORY} \
12
+ --work ${RUNNER_WORKDIR} \
13
+ --unattended \
14
+ --replace
15
+
16
+ remove () {
17
+ ./config.sh remove --unattended --token " ${RUNNER_TOKEN} "
18
+ }
19
+
20
+ trap ' remove; exit 130' INT
21
+ trap ' remove; exit 143' TERM
22
+
23
+ ./run.sh " $* " &
24
+
25
+ wait $!
Original file line number Diff line number Diff line change
1
+ apiVersion : v1
2
+ kind : Secret
3
+ metadata :
4
+ name : github-secret
5
+ type : Opaque
6
+ data :
7
+ GITHUB_PERSONAL_TOKEN : XXXXXXXXXXXXXXXXXXXXXXXXX
8
+ ---
9
+ apiVersion : apps/v1
10
+ kind : Deployment
11
+ metadata :
12
+ name : github-runner
13
+ labels :
14
+ app : github-runner
15
+ spec :
16
+ replicas : 1
17
+ selector :
18
+ matchLabels :
19
+ app : github-runner
20
+ template :
21
+ metadata :
22
+ labels :
23
+ app : github-runner
24
+ spec :
25
+ containers :
26
+ - name : github-runner
27
+ image : aimvector/github-runner:latest
28
+ env :
29
+ - name : GITHUB_OWNER
30
+ value : marcel-dempers
31
+ - name : GITHUB_REPOSITORY
32
+ value : docker-development-youtube-series
33
+ - name : GITHUB_PERSONAL_TOKEN
34
+ valueFrom :
35
+ secretKeyRef :
36
+ name : github-secret
37
+ key : GITHUB_PERSONAL_TOKEN
You can’t perform that action at this time.
0 commit comments