Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit d13b63a

Browse files
authored
Merge pull request #4 from fullstack-devops/feature/helper-scripts
Feature/helper scripts
2 parents 65d0176 + ba072e6 commit d13b63a

File tree

11 files changed

+266
-101
lines changed

11 files changed

+266
-101
lines changed

.github/workflows/build-pr.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ name: Build PR
33
on:
44
pull_request:
55

6+
env:
7+
IMAGE_BASE: "ghcr.io/${{ github.repository_owner }}/github-actions-runner"
8+
69
jobs:
710
generate_infos:
811
uses: fullstack-devops/actions/.github/workflows/generate-build-infos.yml@main
912
secrets:
1013
token: ${{ secrets.GITHUB_TOKEN }}
1114

12-
build:
15+
build_base:
1316
runs-on: ubuntu-latest
1417
needs: generate_infos
1518
steps:
@@ -28,11 +31,18 @@ jobs:
2831
- name: Set up Docker Buildx
2932
uses: docker/setup-buildx-action@v1
3033

31-
- name: Build github-runner-base
34+
- name: Build github-actions-runner:base
35+
uses: docker/build-push-action@v2
36+
with:
37+
context: ./images/base
38+
push: true
39+
tags: |
40+
${{ env.IMAGE_BASE }}:base-pr-${{ github.event.pull_request.number }}
41+
42+
- name: Build github-actions-runner:kaniko-sidecar
3243
uses: docker/build-push-action@v2
3344
with:
34-
context: ./
35-
push: false
45+
context: ./images/kaniko-sidecar
46+
push: true
3647
tags: |
37-
ghcr.io/${{ github.repository_owner }}/github-runner-base:latest
38-
ghcr.io/${{ github.repository_owner }}/github-runner-base:${{needs.generate_infos.outputs.version}}
48+
${{ env.IMAGE_BASE }}:kaniko-sidecar-pr-${{ github.event.pull_request.number }}

.github/workflows/cleanup-pr.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Cleanup PR
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
jobs:
8+
purge-image:
9+
name: Delete image from ghcr.io
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Delete base image
13+
uses: bots-house/ghcr-delete-image-action@v1
14+
with:
15+
owner: ${{ github.repository_owner }}
16+
name: github-actions-runner
17+
token: ${{ secrets.GITHUB_TOKEN }}
18+
tag: base-pr-${{ github.event.pull_request.number }}
19+
- name: Delete kaniko-sidecar image
20+
uses: bots-house/ghcr-delete-image-action@v1
21+
with:
22+
owner: ${{ github.repository_owner }}
23+
name: github-actions-runner
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
tag: kaniko-sidecar-pr-${{ github.event.pull_request.number }}

.github/workflows/create-release.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
branches:
1010
- "main"
1111

12+
env:
13+
IMAGE_BASE: "ghcr.io/${{ github.repository_owner }}/github-actions-runner"
14+
1215
jobs:
1316
create_release:
1417
uses: fullstack-devops/actions/.github/workflows/create-release.yml@main
@@ -34,14 +37,23 @@ jobs:
3437
- name: Set up Docker Buildx
3538
uses: docker/setup-buildx-action@v1
3639

37-
- name: Build and push github-runner-base
40+
- name: Build github-actions-runner:base
41+
uses: docker/build-push-action@v2
42+
with:
43+
context: ./images/base
44+
push: true
45+
tags: |
46+
${IMAGE_BASE}:latest
47+
${IMAGE_BASE}:base-latest
48+
${IMAGE_BASE}:base-${{needs.create_release.outputs.version}}
49+
50+
- name: Build github-actions-runner:kaniko-sidecar
3851
uses: docker/build-push-action@v2
3952
with:
40-
context: ./
53+
context: ./images/kaniko-sidecar
4154
push: true
4255
tags: |
43-
ghcr.io/${{ github.repository_owner }}/github-runner-base:latest
44-
ghcr.io/${{ github.repository_owner }}/github-runner-base:${{needs.create_release.outputs.version}}
56+
${IMAGE_BASE}:kaniko-sidecar-${{needs.create_release.outputs.version}}
4557
4658
publish_release:
4759
runs-on: ubuntu-latest

README.md

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,81 @@ Base Image for github runner images in repo @fullstack-devops/github-runner. Can
99

1010
| Variable | Type | Description |
1111
|-------------------|--------|-------------------------------------------------------------------------------------------------------------------|
12-
| `GH_ORGANIZATION` | string | Points to the GitHub Organisation where the runner should be installed |
12+
| `GH_ORG` | string | Points to the GitHub Organisation where the runner should be installed |
1313
| `GH_ACCESS_TOKEN` | string | Developer Token vor the GitHub Organisation<br> This Token can be personal and is onlv needed during installation |
1414

1515
### Optional environmental variables
1616

1717
For the helm values see the [values.yaml](helm/values.yaml), section `envValues`
1818

19-
| Variable | Type | Default | Description |
20-
|--------------|--------|--------------------------|----------------------------------------------------------------------|
21-
| `GH_URL` | string | `https://github.com` | For GitHub Enterprise support |
22-
| `GH_API_URL` | string | `https://api.github.com` | For GitHub Enterprise support eg.: `https://git.example.com/api/v3/` |
19+
| Variable | Type | Default | Description |
20+
|-------------------|--------|--------------------------|----------------------------------------------------------------------|
21+
| `GH_URL` | string | `https://github.com` | For GitHub Enterprise support |
22+
| `GH_API_ENDPOINT` | string | `https://api.github.com` | For GitHub Enterprise support eg.: `https://git.example.com/api/v3/` |
23+
| `GH_REPO` | string | | installing a runner to a spezific repository |
24+
| `KANIKO_ENABLED` | bool | `false` | enable builds with kaniko (works only with kaniko-sidecar) |
25+
26+
---
27+
28+
## Examples
29+
30+
### docker or podman
31+
32+
If you are using `docker` or `podman` the options and commands are basically the same.
33+
34+
Run registerd to an Organisation:
35+
```bash
36+
podman run -e GH_ORG=fullstack-devops -e GH_ACCESS_TOKEN=ghp_**** github-runner-base:latest
37+
```
38+
39+
Run registerd to an Organisation and Repo:
40+
```bash
41+
podman run -e GH_ORG=fullstack-devops -e GH_REPO=github-runner-testing -e GH_ACCESS_TOKEN=ghp_**** github-runner-base:latest
42+
```
43+
44+
> Replace the `ghp_****` with your own valid personal access token
45+
46+
### docker-compose
47+
48+
```yaml
49+
version: "3"
50+
51+
services:
52+
github-runner:
53+
image: github-runner-base:latest
54+
environment:
55+
GH_ORG: fullstack-devops
56+
GH_ACCESS_TOKEN: ghp_****
57+
```
58+
59+
Build images with kaniko:
60+
```yaml
61+
version: "3"
62+
63+
volumes:
64+
kaniko_workspace:
65+
driver: local
66+
67+
services:
68+
github-action-runner:
69+
image: github-action-runner:base-latest
70+
environment:
71+
GH_ORG: fullstack-devops
72+
GH_ACCESS_TOKEN: ghp_****
73+
KANIKO_ENABLED: "true"
74+
volumes:
75+
- kaniko_workspace:/kaniko/workspace
76+
77+
github-action-runner-kaniko:
78+
image: github-action-runner:kaniko-sidecar-latest
79+
volumes:
80+
- kaniko_workspace:/kaniko/workspace
81+
```
82+
83+
### kubernetes pod
84+
85+
tbd
86+
87+
### helm
88+
89+
tbd

gh-entrypoint.sh

Lines changed: 0 additions & 70 deletions
This file was deleted.
Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
11
FROM ubuntu:20.04
22

3-
COPY export-aarch-infos.sh /export-aarch-infos.sh
4-
RUN chmod +x /export-aarch-infos.sh
5-
63
ARG DEBIAN_FRONTEND=noninteractive
4+
ARG PACKAGES="libffi-dev libicu-dev build-essential libssl-dev ca-certificates jq sed grep git curl wget zip"
75

86
ENV USERNAME="runner"
97
ENV RUNNER_HOME="/home/${USERNAME}/runner"
10-
ENV GH_WORKDIR="/home/${USERNAME}"
8+
9+
ENV GH_RUNNER_WORKDIR="/home/${USERNAME}"
10+
ENV GH_KANIKO_WORKDIR="/kaniko/workspace"
1111

1212
# https://github.com/actions/runner/releases
1313
ENV GH_RUNNER_VERSION=2.289.1
1414
ENV GH_RUNNER_LABELS=ubuntu-20.04
1515

1616
ENV AWESOME_CI_VERSION 0.11.1
1717

18+
# making nessecarry directories
19+
RUN mkdir /helper-scripts \
20+
&& mkdir -p /kaniko/workspace
21+
22+
# Copy image helper scripts
23+
COPY ./helper-scripts/gh-entrypoint.sh /helper-scripts/gh-entrypoint.sh
24+
COPY ./helper-scripts/kaniko-wrapper.sh /helper-scripts/kaniko-wrapper.sh
25+
COPY ./helper-scripts/translate-aarch.sh /helper-scripts/translate-aarch.sh
26+
27+
RUN chmod -R 755 /helper-scripts
28+
1829
# install packages along with jq so we can parse JSON
1930
# add additional packages as necessary
20-
ARG PACKAGES="libffi-dev libicu-dev build-essential libssl-dev ca-certificates jq sed grep git curl wget zip"
21-
2231
RUN apt-get update \
2332
&& apt-get install -y ${PACKAGES} \
2433
&& rm -rf /var/lib/apt/lists/* \
2534
&& apt-get clean
2635

2736
# install awesoeme ci
28-
RUN export ARCH=$(/export-aarch-infos.sh a-short) \
29-
&& curl -L -O https://github.com/eksrvb/awesome-ci/releases/download/${AWESOME_CI_VERSION}/awesome-ci_${AWESOME_CI_VERSION}_${ARCH} \
37+
RUN export ARCH=$(/helper-scripts/translate-aarch.sh a-short) \
38+
&& curl -L -O https://github.com/fullstack-devops/awesome-ci/releases/download/${AWESOME_CI_VERSION}/awesome-ci_${AWESOME_CI_VERSION}_${ARCH} \
3039
&& mv awesome-ci_${AWESOME_CI_VERSION}_${ARCH} /usr/local/src/awesome-ci_${AWESOME_CI_VERSION}_${ARCH} \
3140
&& chmod +x /usr/local/src/awesome-ci_${AWESOME_CI_VERSION}_${ARCH} \
3241
&& ln -s /usr/local/src/awesome-ci_${AWESOME_CI_VERSION}_${ARCH} /usr/local/bin/
@@ -40,23 +49,17 @@ RUN useradd -m $USERNAME \
4049
&& mkdir -p ${RUNNER_HOME}
4150

4251
# Install github runner
43-
RUN export ARCH=$(/export-aarch-infos.sh x-short) \
52+
RUN export ARCH=$(/helper-scripts/translate-aarch.sh x-short) \
4453
&& curl -L -O https://github.com/actions/runner/releases/download/v${GH_RUNNER_VERSION}/actions-runner-linux-${ARCH}-${GH_RUNNER_VERSION}.tar.gz \
4554
&& tar -zxf actions-runner-linux-x64-${GH_RUNNER_VERSION}.tar.gz \
4655
&& rm -f actions-runner-linux-x64-${GH_RUNNER_VERSION}.tar.gz \
4756
&& ./bin/installdependencies.sh \
4857
&& cd ./bin \
4958
&& apt-get clean
5059

51-
# copy over the start script
52-
COPY gh-entrypoint.sh /gh-entrypoint.sh
53-
# make the script executable
54-
RUN chmod +x /gh-entrypoint.sh
55-
5660
RUN chown -R $USERNAME /home/${USERNAME}
57-
RUN chown -R $USERNAME /gh-entrypoint.sh
5861

5962
# set the entrypoint to the entrypoint.sh script
60-
ENTRYPOINT ["/gh-entrypoint.sh"]
63+
ENTRYPOINT ["/helper-scripts/gh-entrypoint.sh"]
6164

6265
USER $USERNAME

0 commit comments

Comments
 (0)