Skip to content

Commit

Permalink
Merge pull request #6 from jpradoar/hosted-runner
Browse files Browse the repository at this point in the history
Hosted runner
  • Loading branch information
jpradoar authored Nov 13, 2024
2 parents e1ecd7d + 6b96df7 commit ee09ae4
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 14 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/00-self-hosted-runner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
##################################
#
# IMPORTANT:
# THIS WORKFLOW REQUIRE YOU RUN
# A RUNNER CONTAINER IN YOUR LAPTOP
# FOR MORE INFORMATION SEE:
#
# ..c2w/GitHostedRunner/README.md
#
##################################
---
name: CI-hosted-runner
on:
push:
branches:
- hosted-runner

env:
DATA: '/dev/null'

jobs:
CI-runner-on-my-laptop:
runs-on: self-hosted

steps:

- name: Show versions
run: |
echo "hello world"
echo "bye bye world"
echo ${{ env.DATA }} > /tmp/test.txt
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
**/demo-inventory.ini
temp/
tmp/
security.md
13 changes: 0 additions & 13 deletions c2w/Dockerfile

This file was deleted.

29 changes: 29 additions & 0 deletions c2w/GitHostedRunner/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:22.04

WORKDIR /actions-runner


ENV RUNNER_NAME="eda-hosted-runner"
ENV RUNNER_WORK_DIRECTORY="_work"
ENV GITHUB_REPOSITORY_URL="https://github.com/jpradoar/event-driven-architecture"
ENV RUNNER_TOKEN=""

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y curl jq sudo tar git && \
rm -rf /var/lib/apt/lists/* && \
curl -o actions-runner-linux-x64-2.320.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.320.0/actions-runner-linux-x64-2.320.0.tar.gz && \
tar xzf ./actions-runner-linux-x64-2.320.0.tar.gz && \
rm -rf actions-runner-linux-x64-2.320.0.tar.gz && \
apt-get clean && \
useradd -m github-runner && \
mkdir -p /actions-runner && \
chown -R github-runner:github-runner /actions-runner && \
echo "github-runner ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

USER github-runner

RUN sudo ./bin/installdependencies.sh && chmod +x ./config.sh ./run.sh

CMD ./config.sh --url $GITHUB_REPOSITORY_URL --token $RUNNER_TOKEN --name $RUNNER_NAME --work $RUNNER_WORK_DIRECTORY --unattended --replace && ./run.sh
20 changes: 20 additions & 0 deletions c2w/GitHostedRunner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Github self-hosted runner in docker container


### Build
docker build -t eda-hosted-runner .


### Run hosted runner
docker run \
--rm \
-itd \
--name eda-hosted-runner \
--hostname eda-hosted-runner \
-e RUNNER_TOKEN=YOUR_GITHUB_RUNNER_TOKEN_HERE \
-e GITHUB_REPOSITORY_URL=https://github.com/jpradoar/event-driven-architecture \
eda-hosted-runner:latest


### Using docker-compsoe
docker-compose up -d
9 changes: 9 additions & 0 deletions c2w/GitHostedRunner/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3.8'
services:
github-runner:
image: eda-hosted-runner:latest
environment:
- RUNNER_TOKEN=YOUR_GITHUB_RUNNER_TOKEN_HERE
- GITHUB_REPOSITORY_URL=https://github.com/jpradoar/event-driven-architecture
stdin_open: true
tty: true
27 changes: 27 additions & 0 deletions c2w/work4all/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y \
curl \
wget \
vim \
netcat-traditional \
ansible \
unzip \
bash \
git \
openssh-client \
jq && \
wget -q https://releases.hashicorp.com/terraform/1.9.5/terraform_1.9.5_linux_386.zip && \
unzip -qq terraform_1.9.5_linux_386.zip && \
mv terraform /usr/local/bin/terraform && \
chmod +x /usr/local/bin/terraform && \
rm LICENSE.txt terraform_1.9.5_linux_386.zip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["/bin/bash"]


2 changes: 1 addition & 1 deletion c2w/README.md → c2w/work4all/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


### Build docker container
docker build -t demo .
docker build -t c2w .


### Create folder to share between container and your local
Expand Down

0 comments on commit ee09ae4

Please sign in to comment.