Skip to content

Commit

Permalink
Merge pull request #6 from terradatum/master
Browse files Browse the repository at this point in the history
Workflows target docker hub by Org/Account.
  • Loading branch information
myoung34 authored Feb 11, 2020
2 parents 7a38b6d + 6ccebdc commit f7405e5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 22 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Publish Docker
name: GitHub Actions Runner in Docker - Latest
on:
push:
branches:
paths-ignore:
- README.md
branches:
- master
- develop

Expand All @@ -11,6 +13,8 @@ jobs:
steps:
- name: Copy Repo Files
uses: actions/checkout@master
- name: Get GitHub organization or user
run: echo ::set-env name=ORG::$(dirname ${GITHUB_REPOSITORY})
- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
Expand All @@ -21,12 +25,14 @@ jobs:
- name: Login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_TOKEN }}
- name: Build
run: docker buildx build -f Dockerfile -t myoung34/github-runner:latest --output "type=image,push=true" --platform linux/amd64,linux/arm/v7,linux/arm64 .
run: docker buildx build -f Dockerfile -t ${ORG}/github-runner:latest --output "type=image,push=true" --platform linux/amd64,linux/arm/v7,linux/arm64 .
ubuntu_bionic_deploy:
runs-on: ubuntu-latest
steps:
- name: Copy Repo Files
uses: actions/checkout@master
- name: Get GitHub organization or user
run: echo ::set-env name=ORG::$(dirname ${GITHUB_REPOSITORY})
- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
Expand All @@ -39,12 +45,14 @@ jobs:
- name: Login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_TOKEN }}
- name: Build
run: docker buildx build -f Dockerfile.ubuntu-bionic -t myoung34/github-runner:ubuntu-bionic --output "type=image,push=true" --platform linux/amd64,linux/arm/v7,linux/arm64 .
run: docker buildx build -f Dockerfile.ubuntu-bionic -t ${ORG}/github-runner:ubuntu-bionic --output "type=image,push=true" --platform linux/amd64,linux/arm/v7,linux/arm64 .
ubuntu_xenial_deploy:
runs-on: ubuntu-latest
steps:
- name: Copy Repo Files
uses: actions/checkout@master
- name: Get GitHub organization or user
run: echo ::set-env name=ORG::$(dirname ${GITHUB_REPOSITORY})
- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
Expand All @@ -57,4 +65,4 @@ jobs:
- name: Login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_TOKEN }}
- name: Build
run: docker buildx build -f Dockerfile.ubuntu-xenial -t myoung34/github-runner:ubuntu-xenial --output "type=image,push=true" --platform linux/amd64,linux/arm/v7,linux/arm64 .
run: docker buildx build -f Dockerfile.ubuntu-xenial -t ${ORG}/github-runner:ubuntu-xenial --output "type=image,push=true" --platform linux/amd64,linux/arm/v7,linux/arm64 .
28 changes: 18 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
name: Publish Docker
name: GitHub Actions Runner in Docker - Release
on:
push:
paths-ignore:
- README.md
tags:
- '*'

jobs:
ubuntu_tag_deploy:
ubuntu_latest_tag:
runs-on: ubuntu-latest
steps:
- name: Copy Repo Files
uses: actions/checkout@master
- name: get version
run: echo "::set-env name=TAG::$(echo ${GITHUB_REF} | sed -e "s/refs\/tags\///g")"
run: echo ::set-env name=TAG::${GITHUB_REF#refs/tags/}
- name: Get GitHub organization or user
run: echo ::set-env name=ORG::$(dirname ${GITHUB_REPOSITORY})
- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
Expand All @@ -22,14 +26,16 @@ jobs:
- name: Login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_TOKEN }}
- name: Build
run: docker buildx build -f Dockerfile -t myoung34/github-runner:${TAG} --output "type=image,push=true" --platform linux/amd64,linux/arm/v7,linux/arm64 .
ubuntu_bionic_deploy:
run: docker buildx build -f Dockerfile -t ${ORG}/github-runner:${TAG} --output "type=image,push=true" --platform linux/amd64,linux/arm/v7,linux/arm64 .
ubuntu_bionic_tag:
runs-on: ubuntu-latest
steps:
- name: Copy Repo Files
uses: actions/checkout@master
- name: get version
run: echo "::set-env name=TAG::$(echo ${GITHUB_REF} | sed -e "s/refs\/tags\///g")"
run: echo ::set-env name=TAG::${GITHUB_REF#refs/tags/}
- name: Get GitHub organization or user
run: echo ::set-env name=ORG::$(dirname ${GITHUB_REPOSITORY})
- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
Expand All @@ -42,14 +48,16 @@ jobs:
- name: Login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_TOKEN }}
- name: Build
run: docker buildx build -f Dockerfile.ubuntu-bionic -t myoung34/github-runner:${TAG}-ubuntu-bionic --output "type=image,push=true" --platform linux/amd64,linux/arm/v7,linux/arm64 .
ubuntu_xenial_deploy:
run: docker buildx build -f Dockerfile.ubuntu-bionic -t ${ORG}/github-runner:${TAG}-ubuntu-bionic --output "type=image,push=true" --platform linux/amd64,linux/arm/v7,linux/arm64 .
ubuntu_xenial_tag:
runs-on: ubuntu-latest
steps:
- name: Copy Repo Files
uses: actions/checkout@master
- name: get version
run: echo "::set-env name=TAG::$(echo ${GITHUB_REF} | sed -e "s/refs\/tags\///g")"
run: echo ::set-env name=TAG::${GITHUB_REF#refs/tags/}
- name: Get GitHub organization or user
run: echo ::set-env name=ORG::$(dirname ${GITHUB_REPOSITORY})
- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
Expand All @@ -62,4 +70,4 @@ jobs:
- name: Login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_TOKEN }}
- name: Build
run: docker buildx build -f Dockerfile.ubuntu-xenial -t myoung34/github-runner:${TAG}-ubuntu-xenial --output "type=image,push=true" --platform linux/amd64,linux/arm/v7,linux/arm64 .
run: docker buildx build -f Dockerfile.ubuntu-xenial -t ${ORG}/github-runner:${TAG}-ubuntu-xenial --output "type=image,push=true" --platform linux/amd64,linux/arm/v7,linux/arm64 .
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUN apt-get update && \
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
&& [[ $(lsb_release -cs) == "eoan" ]] && ( add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu disco stable" ) || ( add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" )\
&& apt-get update \
&& apt-get install -y docker-ce --no-install-recommends \
&& apt-get install -y docker-ce docker-ce-cli containerd.io --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /actions-runner
Expand Down
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,29 @@ Manual:
docker run -it \
-e REPO_URL="https://github.com/myoung34/LEDSpicer" \
-e RUNNER_TOKEN="footoken" \
-v /var/run/docker.sock:/var/run/docker.sock \
myoung34/github-runner:latest
```

Or as an alias:
Or as a shell function (as root):

```
function run-server {
name=github-actions-$(echo $1 | sed 's/\//-/g')
function github-runner {
name=github-runner-${1//\//-}
org=$(dirname $1)
repo=$(basename $1)
tag=${3:-latest}
docker rm -f $name
docker run -d --restart=always -e REPO_URL="https://github.com/$1" -e RUNNER_TOKEN="$2" -v /var/run/docker.sock:/var/run/docker.sock --name $name github-runner:latest
docker run -d --restart=always \
-e REPO_URL="https://github.com/${org}/${repo}" \
-e RUNNER_TOKEN="$2" \
-e RUNNER_NAME="linux-${repo}" \
-v /var/run/docker.sock:/var/run/docker.sock \
--name $name ${org}/github-runner:${tag}
}
run-server your-account/your-repo AARGHTHISISYOURGHACTIONSTOKEN
run-server your-account/some-other-repo ARGHANOTHERGITHUBACTIONSTOKEN
github-runner your-account/your-repo AARGHTHISISYOURGHACTIONSTOKEN
github-runner your-account/some-other-repo ARGHANOTHERGITHUBACTIONSTOKEN ubuntu-xenial
```

Nomad:
Expand Down

0 comments on commit f7405e5

Please sign in to comment.