batman
Some checks failed
Build and Push to Forgejo Registry / checkout (push) Failing after 6s

This commit is contained in:
pika 2025-04-12 12:46:33 +02:00
commit a31df71d2b
3 changed files with 101 additions and 0 deletions

View file

@ -0,0 +1,29 @@
name: Build and Push to Forgejo Registry
on:
push:
branches: [main]
paths:
- '**/Dockerfile'
- '**/build-and-push.yml'
# schedule:
# - cron: "0 0 * * 0" # Weekly at 00:00 UTC Sunday
jobs:
checkout:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to registry
uses: docker/login-actions@v3
with:
registry: ${{ vars.FORGEJO_URL }}
username: ${{ vars.FORGEJO_USERNAME }}
password: ${{ secrets.FORGEJO_PACKAGE_TOKEN }}
- name: Build 'n Push
run: |
docker build -t git.k4li.de/docker/forgejo-runner:latest .
docker push git.k4li.de/docker/forgejo-runner:latest

10
Dockerfile Normal file
View file

@ -0,0 +1,10 @@
FROM ghcr.io/catthehacker/ubuntu:act-22.04
RUN export RUNNER_VERSION=$(curl -X 'GET' https://data.forgejo.org/api/v1/repos/forgejo/runner/releases/latest | jq .name -r | cut -c 2-) && wget -O forgejo-runner https://code.forgejo.org/forgejo/runner/releases/download/v${RUNNER_VERSION}/forgejo-runner-${RUNNER_VERSION}-linux-amd64 && chmod +x forgejo-runner && mv forgejo-runner /usr/bin/
RUN useradd --create-home runner && usermod -aG docker runner
USER runner
WORKDIR /home/runner
CMD ["forgejo-runner", "daemon"]

62
README.md Normal file
View file

@ -0,0 +1,62 @@
## Forgejo-Runner
This is a minor modifyed version of `ghcr.io/catthehacker/ubuntu:act-22.04`. It houses the forgejo-runner binary and executes it on startup with "daemon".
This runner needs dind to execute docker commands in a secured environment.
```yaml
services:
docker-in-docker:
image: docker:dind
container_name: "docker_dind"
hostname: docker
privileged: "true"
command: ["dockerd", "-H", "tcp://0.0.0.0:2375", "--tls=false"]
restart: "unless-stopped"
pika-runner:
image: pika-runner:latest
depends_on:
- docker-in-docker
environment:
DOCKER_HOST: "tcp://docker:2375"
volumes:
- ./config:/home/runner
```
Now run `docker compose run --rm pika-runner forgejo-runner register`
You should be asked to input your forgejo url like `https://git.k4li.de/`, your runner token, which you aquire in admin mode when adding runners. Then it askes for the label to use. In my case, this label works perfectly fine for me `self-hosted:host://-self-hosted`
After this, you can successfully build docker images, and use almost every github actions workflow you like. INSIDE DOCKER!!
example workflow that works:
> [!INFO]
> This is my workflow to push my modifyed caddy container to my registry
```yaml workflow.yml
name: Build and Push to Forgejo Registry
on:
push:
branches: [main]
jobs:
checkout:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to Forgejo Container Registry
uses: docker/login-action@v3
with:
registry: git.k4li.de
username: ${{ vars.FORGEJO_USERNAME }}
password: ${{ vars.FORGEJO_PASSWORD }}
- name: Build n Push
run: |
docker build -t git.k4li.de/docker/caddy:latest .
docker push git.k4li.de/docker/caddy:latest
```