Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hosted runner #6

Merged
merged 6 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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