This commit is contained in:
TingluoHuang
2020-09-03 01:12:46 -04:00
parent 58afa42109
commit 7da6739eae
5 changed files with 35 additions and 17 deletions

View File

@@ -40,6 +40,10 @@ COPY ./src/Misc/jobstart.sh /actions-runner/jobstart.sh
COPY ./src/Misc/jobrunning.sh /actions-runner/jobrunning.sh
COPY ./src/Misc/jobcomplete.sh /actions-runner/jobcomplete.sh
# Allow runner to run as root
ENV RUNNER_ALLOW_RUNASROOT=1
RUN /actions-runner/download-runner.sh
RUN rm -f /actions-runner/download-runner.sh

View File

@@ -4,7 +4,11 @@ metadata:
name: auto-scale-runners
spec:
replicas: 1
maxRunnerLimit: 15
maxRunnerLimit: 5
template:
spec:
repository: monalisa/main123
configURL: https://github.com/bbq-beets/ting-test
githubTokenSecretKeyRef:
name: githubtoken
key: GITHUB_PAT

View File

@@ -4,14 +4,11 @@ metadata:
name: auto-scale-runners
spec:
minReplicas: 1
maxReplicas: 10
maxReplicas: 5
configURL: https://github.com/TingluoHuang/example-services
githubTokenSecretKeyRef:
name: githubtoken
key: GITHUB_PAT
template:
spec:
organization: monalisa
group: default
repository: main123
gitHubAdminToken: 62c13e14e947958516c103a9584f66227697c447
imagePullPolicy: Always
env:
- name: K8S_HOST_IP
value: "192.168.120.1"
setupDockerInDocker: true

View File

@@ -9,12 +9,13 @@ function fatal() {
[ -n "${GITHUB_PAT:-""}" ] || fatal "GITHUB_PAT variable must be set"
[ -n "${RUNNER_CONFIG_URL:-""}" ] || fatal "RUNNER_CONFIG_URL variable must be set"
[ -n "${RUNNER_NAME:-""}" ] || fatal "RUNNER_NAME variable must be set"
if [ -n "${RUNNER_NAME}" ]; then
# Use container id to gen unique runner name if name not provide
CONTAINER_ID=$(cat /proc/self/cgroup | head -n 1 | tr '/' '\n' | tail -1 | cut -c1-12)
RUNNER_NAME="actions-runner-${CONTAINER_ID}"
fi
# if [ -n "${RUNNER_NAME}" ]; then
# # Use container id to gen unique runner name if name not provide
# CONTAINER_ID=$(cat /proc/self/cgroup | head -n 1 | tr '/' '\n' | tail -1 | cut -c1-12)
# RUNNER_NAME="actions-runner-${CONTAINER_ID}"
# fi
# if the scope has a slash, it's a repo runner
# orgs_or_repos="orgs"

View File

@@ -140,6 +140,11 @@ namespace GitHub.Runner.Worker
executionContext.JobContext.Container["network"] = new StringContextData(containerNetwork);
executionContext.Output("##[endgroup]");
if (Environment.GetEnvironmentVariable("K8S_POD_NAME") != null)
{
IOUtil.CopyDirectory(HostContext.GetDirectory(WellKnownDirectory.Externals), Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Work), "__externals_copy"), CancellationToken.None);
}
foreach (var container in containers)
{
container.ContainerNetwork = containerNetwork;
@@ -236,7 +241,14 @@ namespace GitHub.Runner.Worker
#if OS_WINDOWS
container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Externals), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Externals))));
#else
container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Externals), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Externals)), true));
if (Environment.GetEnvironmentVariable("K8S_POD_NAME") != null)
{
container.MountVolumes.Add(new MountVolume(Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Work), "__externals_copy"), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Externals)), true));
}
else
{
container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Externals), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Externals)), true));
}
#endif
container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Temp), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Temp))));
container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Actions), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Actions))));