Compare commits

...
12 Commits
Author SHA1 Message Date
Marcus Young 209276897a Bump to 2.169.0 2020-04-08 12:11:31 -05:00
myoung34andGitHub ca85306837 Merge pull request #13 from patst/master
Update examples to match WORKDIR to volume mounts
2020-04-07 15:12:46 -05:00
patstandGitHub 040ac6cfca Fix volume mount to match WORKDIR 2020-04-07 21:35:05 +02:00
patstandGitHub 176dcf0d33 Fix RUNNER_WORKDIR path in README 2020-04-07 21:33:38 +02:00
Marcus Young a033875662 Bump to 2.168.0 2020-04-03 12:43:29 -05:00
Marcus Young 77bb89fd23 Add MIT license 2020-03-31 14:28:50 -05:00
myoung34andGitHub 97b9681fdf Merge pull request #10 from terradatum/master
Only one runner can use the same RUNNER_WORKDIR if it is shared storage.
2020-03-13 20:03:52 -05:00
G. Richard Bellamy b024ba2957 Only one runner can use the same RUNNER_WORKDIR if it is shared storage.
The "Set up job" step at the beginning of a workflow will delete the `_actions` directory. Therefore,
you cannot have more than one container running on the same Docker host sharing storage via a volume
mount (e.g. `/tmp/github-runner`) used by `RUNNER_WORKDIR`.

https://github.community/t5/GitHub-Actions/Does-self-hosted-runner-clear-all-previous-actions-during-quot/m-p/50061
2020-03-13 14:14:36 -07:00
myoung34andGitHub f8953c67a1 Update README.md 2020-03-08 11:10:09 -05:00
myoung34andGitHub 20853b4e27 Update README.md 2020-03-08 11:09:18 -05:00
myoung34andGitHub 983dd6593c Merge pull request #8 from stevenpall/master
Get Runner Token Automatically
2020-02-26 23:02:41 -06:00
Steven Pall 46f65587e3 Get RUNNER_TOKEN Automatically
- Add the ability to specify a personal access token to use for calling the new Actions API for a runner token
- Add `jq` and `docker-compose` to the `Dockerfile`
- Update `README.md`
2020-02-26 16:39:31 -08:00
4 changed files with 89 additions and 19 deletions
+5 -2
View File
@@ -2,7 +2,7 @@ FROM ubuntu:rolling
LABEL maintainer="3vilpenguin@gmail.com"
ARG GIT_VERSION="2.23.0"
ARG GH_RUNNER_VERSION="2.165.2"
ARG GH_RUNNER_VERSION="2.169.0"
ARG TARGETPLATFORM
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
@@ -22,6 +22,7 @@ RUN apt-get update && \
liblttng-ust0 \
libcurl4-openssl-dev \
inetutils-ping \
jq \
&& rm -rf /var/lib/apt/lists/* \
&& c_rehash \
&& cd /tmp \
@@ -40,6 +41,9 @@ RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
&& apt-get install -y docker-ce docker-ce-cli containerd.io --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
RUN curl -sL "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \
&& chmod +x /usr/local/bin/docker-compose
WORKDIR /actions-runner
COPY install_actions.sh /actions-runner
@@ -47,7 +51,6 @@ RUN chmod +x /actions-runner/install_actions.sh \
&& /actions-runner/install_actions.sh ${GH_RUNNER_VERSION} ${TARGETPLATFORM} \
&& rm /actions-runner/install_actions.sh
WORKDIR /_work
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Marcus Young
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+39 -15
View File
@@ -1,7 +1,7 @@
Docker Github Actions Runner
============================
This will run the [new self-hosted github actions runners](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/hosting-your-own-runners) with docker-in-docker
This will run the [new self-hosted github actions runners](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/hosting-your-own-runners).
This has been tested and verified on:
@@ -9,23 +9,29 @@ This has been tested and verified on:
* armhf
* armv7
* arm64
**NOTE: Only one runner can use the same RUNNER_WORKDIR if it is shared storage.**
## Examples ##
Manual:
### Note ###
If you're using a RHEL based OS with SELinux, add `--security-opt=label=disable` to prevent [permission denied](https://github.com/myoung34/docker-github-actions-runner/issues/9)
### Manual ###
```
docker run -d --restart always --name github-runner \
-e REPO_URL="https://github.com/myoung34/repo" \
-e RUNNER_NAME="foo-runner" \
-e RUNNER_TOKEN="footoken" \
-e RUNNER_WORKDIR="/tmp/github-runner" \
-e RUNNER_WORKDIR="/tmp/github-runner-your-repo" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/github-runner:/tmp/github-runner \
-v /tmp/github-runner-your-repo:/tmp/github-runner-your-repo \
myoung34/github-runner:latest
```
Or as a shell function (as root):
Or shell wrapper:
```
function github-runner {
@@ -38,9 +44,9 @@ function github-runner {
-e REPO_URL="https://github.com/${org}/${repo}" \
-e RUNNER_TOKEN="$2" \
-e RUNNER_NAME="linux-${repo}" \
-e RUNNER_WORKDIR="/tmp/github-runner" \
-e RUNNER_WORKDIR="/tmp/github-runner-${repo}" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/github-runner:/tmp/github-runner \
-v /tmp/github-runner-${repo}:/tmp/github-runner-${repo} \
--name $name ${org}/github-runner:${tag}
}
@@ -48,7 +54,7 @@ github-runner your-account/your-repo AARGHTHISISYOURGHACTIONSTOKEN
github-runner your-account/some-other-repo ARGHANOTHERGITHUBACTIONSTOKEN ubuntu-xenial
```
Nomad:
### Nomad ###
```
job "github_runner" {
@@ -61,7 +67,7 @@ job "github_runner" {
env {
REPO_URL = "https://github.com/your-account/your-repo"
RUNNER_TOKEN = "footoken"
RUNNER_WORKDIR = "/tmp/github-runner"
RUNNER_WORKDIR = "/tmp/github-runner-your-repo"
}
config {
@@ -69,14 +75,14 @@ job "github_runner" {
image = "myoung34/github-runner:latest"
volumes = [
"/var/run/docker.sock:/var/run/docker.sock",
"/tmp/github-runner:/tmp/github-runner",
"/tmp/github-runner-your-repo:/tmp/github-runner-your-repo",
]
}
}
}
```
Kubernetes:
### Kubernetes ###
```
apiVersion: apps/v1
@@ -100,8 +106,7 @@ spec:
path: /var/run/docker.sock
- name: workdir
hostPath:
path: /tmp/github-runner
containers:
path: /tmp/github-runner-your-repo
containers:
- name: runner
image: myoung34/github-runner:latest
@@ -110,13 +115,17 @@ spec:
value: footoken
- name: REPO_URL
value: https://github.com/your-account/your-repo
- name: RUNNER_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: RUNNER_WORKDIR
value: /tmp/github-runner
value: /tmp/github-runner-your-repo
volumeMounts:
- name: dockersock
mountPath: /var/run/docker.sock
- name: workdir
mountPath: /tmp/github-runner
mountPath: /tmp/github-runner-your-repo
```
## Usage From GH Actions Workflow ##
@@ -136,3 +145,18 @@ jobs:
- name: build packages
run: make all
```
## Automatically Acquiring a Runner Token ##
A runner token can be automatically acquired at runtime if `ACCESS_TOKEN` (a GitHub personal access token) is a supplied. This uses the [GitHub Actions API](https://developer.github.com/v3/actions/self_hosted_runners/#create-a-registration-token). e.g.:
```
docker run -d --restart always --name github-runner \
-e ACCESS_TOKEN="footoken" \
-e REPO_URL="https://github.com/myoung34/repo" \
-e RUNNER_NAME="foo-runner" \
-e RUNNER_WORKDIR="/tmp/github-runner-your-repo" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/github-runner-your-repo:/tmp/github-runner-your-repo \
myoung34/github-runner:latest
```
+24 -2
View File
@@ -1,7 +1,29 @@
#!/bin/bash
export RUNNER_ALLOW_RUNASROOT=1
export PATH=$PATH:/actions-runner
_RUNNER_NAME=${RUNNER_NAME:-default}
_RUNNER_WORKDIR=${RUNNER_WORKDIR:-/_work}
config.sh --url "${REPO_URL}" --token "${RUNNER_TOKEN}" --name "${_RUNNER_NAME}" --work "${_RUNNER_WORKDIR}"
exec run.sh
if [[ -n "${ACCESS_TOKEN}" ]]; then
URI=https://api.github.com
API_VERSION=v3
API_HEADER="Accept: application/vnd.github.${API_VERSION}+json"
AUTH_HEADER="Authorization: token ${ACCESS_TOKEN}"
_PROTO="$(echo "${REPO_URL}" | grep :// | sed -e's,^\(.*://\).*,\1,g')"
_URL="$(echo "${REPO_URL/${_PROTO}/}")"
_PATH="$(echo "${_URL}" | grep / | cut -d/ -f2-)"
_ACCOUNT="$(echo "${_PATH}" | cut -d/ -f1)"
_REPO="$(echo "${_PATH}" | cut -d/ -f2)"
RUNNER_TOKEN="$(curl -XPOST -fsSL \
-H "${AUTH_HEADER}" \
-H "${API_HEADER}" \
"${URI}/repos/${_ACCOUNT}/${_REPO}/actions/runners/registration-token" \
| jq -r '.token')"
fi
./config.sh --url "${REPO_URL}" --token "${RUNNER_TOKEN}" --name "${_RUNNER_NAME}" --work "${_RUNNER_WORKDIR}"
./run.sh