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

Commit 360ef88

Browse files
committed
add kaniko-sidecar + workflows
1 parent d2873d2 commit 360ef88

File tree

6 files changed

+60
-7
lines changed

6 files changed

+60
-7
lines changed

.github/workflows/build-pr.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
secrets:
1010
token: ${{ secrets.GITHUB_TOKEN }}
1111

12-
build:
12+
build_base:
1313
runs-on: ubuntu-latest
1414
needs: generate_infos
1515
steps:
@@ -28,11 +28,18 @@ jobs:
2828
- name: Set up Docker Buildx
2929
uses: docker/setup-buildx-action@v1
3030

31-
- name: Build github-runner-base
31+
- name: Build github-actions-runner:base
3232
uses: docker/build-push-action@v2
3333
with:
34-
context: ./
34+
context: ./images/base
3535
push: false
3636
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}}
37+
ghcr.io/${{ github.repository_owner }}/github-actions-runner:base-pr-${{ github.event.pull_request.number }}
38+
39+
- name: Build github-actions-runner:kaniko-sidecar
40+
uses: docker/build-push-action@v2
41+
with:
42+
context: ./images/kaniko-sidecar
43+
push: false
44+
tags: |
45+
ghcr.io/${{ github.repository_owner }}/github-actions-runner: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 }}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ For the helm values see the [values.yaml](helm/values.yaml), section `envValues`
2121
| `GH_URL` | string | `https://github.com` | For GitHub Enterprise support |
2222
| `GH_API_ENDPOINT` | string | `https://api.github.com` | For GitHub Enterprise support eg.: `https://git.example.com/api/v3/` |
2323
| `GH_REPO` | string | | installing a runner to a spezific repository |
24+
| `KANIKO_ENABLED` | bool | `false` | enable builds with kaniko (works only with kaniko-sidecar) |
2425

2526
---
2627

@@ -69,14 +70,14 @@ services:
6970
environment:
7071
GH_ORG: fullstack-devops
7172
GH_ACCESS_TOKEN: ghp_****
73+
KANIKO_ENABLED: "true"
7274
volumes:
7375
- kaniko_workspace:/kaniko/workspace
7476

7577
github-action-runner-kaniko:
7678
image: github-action-runner:kaniko-sidecar-latest
7779
volumes:
7880
- kaniko_workspace:/kaniko/workspace
79-
8081
```
8182
8283
### kubernetes pod

images/base/helper-scripts/gh-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if [ -z ${RUNNER_HOME} ]; then
4040
exit 1
4141
fi
4242

43-
if [ "$KANIKO_ENABLED" == "1" ]; then
43+
if [ "$KANIKO_ENABLED" == "true" ]; then
4444
readonly GH_WORKDIR=$GH_KANIKO_WORKDIR
4545
echo "Build container via Kaniko: enabled"
4646
else

images/kaniko-sidecar/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM gcr.io/kaniko-project/executor:v1.8.0-debug
2+
3+
COPY kaniko-entrypoint.sh /kaniko/kaniko-entrypoint.sh
4+
WORKDIR /
5+
ENTRYPOINT ["/kaniko/kaniko-entrypoint.sh"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/busybox/sh
2+
while [ true ]
3+
do
4+
echo "kaniko container waiting for pipe"
5+
while [ ! -p /kaniko/workspace/log ]; do sleep 1; done
6+
echo "kaniko container executing"
7+
/busybox/sh /kaniko/workspace/start.sh > /kaniko/workspace/log 2>&1
8+
echo $? > /kaniko/workspace/returncode
9+
if [ ! -f "/busybox/sh" ]; then
10+
echo "kaniko self destructed. restarting container"
11+
exit 1
12+
fi
13+
echo "kaniko container end"
14+
sleep 5
15+
done

0 commit comments

Comments
 (0)