GithubHelp home page GithubHelp logo

julienkode / github-actions-runner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from samber/github-actions-runner

0.0 1.0 0.0 99 KB

✅ Docker images for starting self-hosted Github Actions runner(s).

License: MIT License

Dockerfile 41.04% Java 15.09% PHP 20.03% Shell 23.85%

github-actions-runner's Introduction

👌 Github Actions self-hosted runner provisioning

Simple Docker images for starting self-hosted Github Actions runner(s).

Screenshot Github self-hosted runners

Github official documentation for self-hosted runners.

🚀 Quick start

Add your self-hosted runner from your repository settings:

  • Go to repository > settings > actions
  • Click on "Add runner"
  • Copy the URL and token
# start a runner on your server

$ docker run -d \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /tmp:/tmp \
    -e GH_REPOSITORY=xxxxxxxxxxxx \
    -e GH_RUNNER_TOKEN=xxxxxxxxxxxxx \
    -e GH_RUNNER_LABELS=label1,label2 \
    samber/github-actions-runner:latest
# .github/workflows/main.yml

on:
  - push

jobs:
  example:
    runs-on: self-hosted
    steps:
      - name: Hello world
        run: echo "Hello world"

Runners with language support (NodeJS, Python3...)

Just select your runner in the Docker image tag.

Currently available:

  • samber/github-actions-runner:node
  • samber/github-actions-runner:golang
  • samber/github-actions-runner:python
  • samber/github-actions-runner:java
  • samber/github-actions-runner:php
# start a NodeJS runner

$ docker run -d \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /tmp:/tmp \
    -e GH_REPOSITORY=xxxxxxxxxxxx \
    -e GH_RUNNER_TOKEN=xxxxxxxxxxxxx \
    -e GH_RUNNER_LABELS=node \
    samber/github-actions-runner:node
# .github/workflows/main.yml

on:
  - push

jobs:
  frontend:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v2
      - name: Fetch dependencies
        run: yarn
      - name: Build application
        run: npm run build
      - name: Execute tests
        run: npm run test

Missing language support ?

You just need to write a Dockerfile starting with FROM samber/github-actions-runner:latest.

You can contribute to this repository or create your own Docker image.

💡 Docker compose

Simple runner

version: '3'

services:

  runner:
    image: samber/github-actions-runner:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /tmp:/tmp
    environment:
      - GH_REPOSITORY=xxxxxxxxxxxx
      - GH_RUNNER_TOKEN=xxxxxxxxxxxxx
      - GH_RUNNER_LABELS=label1,label2 \
    restart: unless-stopped
$ docker-compose up -d

Concurrent executors

$ docker-compose scale runner=3

Runners with language support

You will need to register multiple runners, with different name+tokens.

In the following example, we create 2 self-hosted runners: node and golang, with respective tag: "node" and "golang". We will start 2 instances of each.

version: '3'

services:

  runner-node:
    image: samber/github-actions-runner:node
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /tmp:/tmp
    environment:
      - GH_REPOSITORY=yyyyyyyyyyyyy
      - GH_RUNNER_TOKEN=xxxxxxxxxxxxx
      - GH_RUNNER_LABELS=node \
    restart: unless-stopped

  runner-golang:
    image: samber/github-actions-runner:golang
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /tmp:/tmp
    environment:
      - GH_REPOSITORY=yyyyyyyyyyyyy
      - GH_RUNNER_TOKEN=zzzzzzzzzzzzz
      - GH_RUNNER_LABELS=golang \
    restart: unless-stopped
$ docker-compose up -d
$ docker-compose scale runner-node=2 runner-golang=2
# .github/workflows/main.yml

on:
  - push

jobs:

  frontend:
    runs-on: [self-hosted, node]
    steps:
      - uses: actions/checkout@v2
      - name: Fetch dependencies
        run: yarn
      - name: Build application
        run: npm run build
      - name: Execute tests
        run: npm run test

  api:
    runs-on: [self-hosted, golang]
    steps:
      - uses: actions/checkout@v2
      - name: Fetch dependencies
        run: go mod download
      - name: Build application
        run: go build -o hello-world
      - name: Execute tests
        run: go testt

🤯 Advanced

Run as root

For whatever (bad 😅) reason, if you need to start runners as root, you have to set container user to root, and add an empty RUNNER_ALLOW_RUNASROOT environment variables.

🔬 Build

docker build -f Dockerfile          -t samber/github-actions-runner:latest  -t samber/github-actions-runner:2.272.0 .
docker build -f Dockerfile.node     -t samber/github-actions-runner:node    -t samber/github-actions-runner:node-2.272.0 .
docker build -f Dockerfile.golang   -t samber/github-actions-runner:golang  -t samber/github-actions-runner:golang-2.272.0 .
docker build -f Dockerfile.python   -t samber/github-actions-runner:python  -t samber/github-actions-runner:python-2.272.0 .
docker build -f Dockerfile.java     -t samber/github-actions-runner:java    -t samber/github-actions-runner:java-2.272.0 .
docker build -f Dockerfile.php      -t samber/github-actions-runner:php     -t samber/github-actions-runner:php-2.272.0 .

docker push samber/github-actions-runner:latest
docker push samber/github-actions-runner:2.272.0

docker push samber/github-actions-runner:node
docker push samber/github-actions-runner:node-2.272.0

docker push samber/github-actions-runner:golang
docker push samber/github-actions-runner:golang-2.272.0

docker push samber/github-actions-runner:python
docker push samber/github-actions-runner:python-2.272.0

docker push samber/github-actions-runner:java
docker push samber/github-actions-runner:java-2.272.0

docker push samber/github-actions-runner:php
docker push samber/github-actions-runner:php-2.272.0

♻️ Host cleanup

Clean stopped containers on a daily basis:

$ crontab -e

0 0 * * * /usr/bin/docker system prune -f

🤝 Contributing

This project is open source and contributions from community (you!) are welcome.

There are many ways to contribute: writing code, documentation, reporting issues...

Author

👤 Samuel Berthe

💫 Show your support

Give a ⭐️ if this project helped you!

support us

📝 License

Copyright © 2020 Samuel Berthe.

This project is MIT licensed.

github-actions-runner's People

Contributors

samber avatar kthompson avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.