forked from marcel-dempers/docker-development-youtube-series
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6cd1038
commit c5214cf
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
FROM debian:buster | ||
|
||
ARG RUNNER_VERSION="2.169.1" | ||
|
||
ENV GITHUB_PERSONAL_TOKEN "" | ||
ENV GITHUB_OWNER "" | ||
ENV GITHUB_REPOSITORY "" | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
curl \ | ||
sudo \ | ||
git \ | ||
jq \ | ||
tar \ | ||
gnupg2 \ | ||
apt-transport-https \ | ||
ca-certificates \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN useradd -m github && \ | ||
usermod -aG sudo github && \ | ||
echo "%sudo ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
|
||
#setup docker runner | ||
RUN curl -sSL https://get.docker.com/ | sh | ||
RUN usermod -aG docker github | ||
|
||
USER github | ||
WORKDIR /home/github | ||
|
||
RUN curl -O -L https://github.com/actions/runner/releases/download/v$RUNNER_VERSION/actions-runner-linux-x64-$RUNNER_VERSION.tar.gz | ||
RUN tar xzf ./actions-runner-linux-x64-$RUNNER_VERSION.tar.gz | ||
RUN sudo ./bin/installdependencies.sh | ||
|
||
COPY --chown=github:github entrypoint.sh ./entrypoint.sh | ||
RUN sudo chmod u+x ./entrypoint.sh | ||
|
||
ENTRYPOINT ["/home/github/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
registration_url="https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPOSITORY}/actions/runners/registration-token" | ||
echo "Requesting registration URL at '${registration_url}'" | ||
|
||
payload=$(curl -sX POST -H "Authorization: token ${GITHUB_PAT}" ${registration_url}) | ||
export RUNNER_TOKEN=$(echo $payload | jq .token --raw-output) | ||
|
||
./config.sh \ | ||
--name $(hostname) \ | ||
--token ${RUNNER_TOKEN} \ | ||
--url https://github.com/${GITHUB_OWNER}/${GITHUB_REPOSITORY} \ | ||
--work ${RUNNER_WORKDIR} \ | ||
--unattended \ | ||
--replace | ||
|
||
remove() { | ||
./config.sh remove --unattended --token "${RUNNER_TOKEN}" | ||
} | ||
|
||
trap 'remove; exit 130' INT | ||
trap 'remove; exit 143' TERM | ||
|
||
./run.sh "$*" & | ||
|
||
wait $! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: github-secret | ||
type: Opaque | ||
data: | ||
GITHUB_PERSONAL_TOKEN: XXXXXXXXXXXXXXXXXXXXXXXXX | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: github-runner | ||
labels: | ||
app: github-runner | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: github-runner | ||
template: | ||
metadata: | ||
labels: | ||
app: github-runner | ||
spec: | ||
containers: | ||
- name: github-runner | ||
image: aimvector/github-runner:latest | ||
env: | ||
- name: GITHUB_OWNER | ||
value: marcel-dempers | ||
- name: GITHUB_REPOSITORY | ||
value: docker-development-youtube-series | ||
- name: GITHUB_PERSONAL_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
name: github-secret | ||
key: GITHUB_PERSONAL_TOKEN |