Compare commits

..

No commits in common. "95a86b62ef8215e69cb9d838de15b7406c961645" and "ca84c6f04104604aca0ac15ee7473e13c1e46471" have entirely different histories.

2 changed files with 34 additions and 52 deletions

View file

@ -1,54 +1,36 @@
# Forgejo Runner # README for Docker Image Build and Publish Workflows
The entrypoint script sets up and runs the `forgejo-runner`, including configuring the runner file and managing the registration process. The script supports custom configurations for Forgejo, Docker, and environment variables. ## Overview
It is important to note that using the `command` docker flag will override the entrypoint *by design*, this is to make it compatible with older manual configurations This repository contains two GitHub Actions workflows that automate the building and publishing of Docker images to an OCI registry.
## Environment Variables ### Workflows
### Required Variables 1. **On Commit to Main**
- **Trigger:** Activates on commits to the `main` branch (tags are excluded).
- **Purpose:** Builds and publishes a Docker image for each commit.
> Only needed during registration of the runner. 2. **On Tag Push**
> After initial registration the runner operates off of the runner. - **Trigger:** Activates when a new tag is pushed.
- **`FORGEJO_URL`**: The URL of the Forgejo instance. Default: `http://forgejo:3000` Only needed during registration of the runner. - **Purpose:** Builds and publishes a Docker image for the tag and tags it as `latest`.
- **`FORGEJO_SECRET`**: Secret used for Forgejo runner creation. Only needed during registration of the runner.
- **`RUNNER_TOKEN`**: Token used for runner registration. Only needed during registration of the runner.
## Prerequisites
- **`RUNNER_NAME`** (Optional): Name for the runner. Default: The hostname of the container. - **Secrets Needed:**
- `OCI_TOKEN`: Your OCI registry token.
- `OCI_USER`: Your OCI registry username.
### Optional Configuration Variables ## How to Use
- **`DEBUG`**: Enables debug logging. Default: `false`
- **`RUNNER_FILE`**: Path to the runner file. Default: `runner.json` 1. **Clone the Repository:** Get a local copy of this repository.
- **`CONFIG_FILE`**: Path to the configuration file. Default: `/data/config.yml` 2. **Modify Dockerfile:** Update the `Dockerfile` for your application.
- **`ENV_FILE`**: Path to the environment file. Default: `/data/.env` 3. **Push Changes:** Push changes to the `main` branch or create a new tag.
- **`RUNNER_LABELS`**: Labels to attach to the runner. Default: 4. **Check Workflow Status:** View the Actions tab in Forgjo to monitor workflow runs.
- `docker:docker://code.forgejo.org/oci/node:20-bookworm`
- `ubuntu-22.04:docker://catthehacker/ubuntu:act-22.04`
- **`DOCKER_HOST`**: Docker host URL. Default: `tcp://docker:2367`
- **`DOCKER_CERT_PATH`**: Path to Docker certificates. Default: `/certs/client`
- **`DOCKER_TLS_VERIFY`**: Whether Docker TLS verification is enabled. Default: `1`
- **`DOCKER_PRIVILEGED`**: Whether to run the container in privileged mode. Default: `false`
- **`MAX_REG_ATTEMPTS`**: Maximum number of registration attempts. Default: `10`
- **`SKIP_WAIT`**: Whether to skip the wait before starting the runner. Default: `false`
## Notes ## Notes
- The entrypoint will automatically create and configure a `config.yml` file if it does not already exist. - Ensure your Docker environment is compatible with multi-platform builds if necessary.
- The runner will attempt to connect to the Forgejo instance and register the runner automatically.
- If `FORGEJO_SECRET` is not provided, the runner will use the `RUNNER_TOKEN` for registration.
- If the registration fails, the script will retry according to the `MAX_REG_ATTEMPTS` value.
## Troubleshooting
- **Invalid Configuration**: If the runner does not start, ensure that all required environment variables are set and that the configuration file is valid.
- **Network Issues**: Check your `DOCKER_HOST` and `DOCKER_CERT_PATH` to ensure that Docker is properly configured for secure communication.
## License ## License
This image is distributed under the MIT license. See the LICENSE file for more details. This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

View file

@ -102,7 +102,7 @@ if [[ ! -s "${RUNNER_FILE}" ]]; then
--instance "${FORGEJO_URL:-http://forgejo:3000}" \ --instance "${FORGEJO_URL:-http://forgejo:3000}" \
--name "${RUNNER_NAME:-$(hostname)}" \ --name "${RUNNER_NAME:-$(hostname)}" \
--secret "${FORGEJO_SECRET}" \ --secret "${FORGEJO_SECRET}" \
${CONFIG_ARG} \ ${CONFIG_ARG}\
${EXTRA_ARGS} 2>&1 | tee /tmp/reg.log ${EXTRA_ARGS} 2>&1 | tee /tmp/reg.log
else else
run_command forgejo-runner register \ run_command forgejo-runner register \
@ -110,7 +110,7 @@ if [[ ! -s "${RUNNER_FILE}" ]]; then
--name "${RUNNER_NAME:-$(hostname)}" \ --name "${RUNNER_NAME:-$(hostname)}" \
--token "${RUNNER_TOKEN}" \ --token "${RUNNER_TOKEN}" \
--no-interactive \ --no-interactive \
${CONFIG_ARG} \ ${CONFIG_ARG}\
${EXTRA_ARGS} 2>&1 | tee /tmp/reg.log ${EXTRA_ARGS} 2>&1 | tee /tmp/reg.log
fi fi
cat /tmp/reg.log | grep -E 'connection successful|registered successfully' >/dev/null cat /tmp/reg.log | grep -E 'connection successful|registered successfully' >/dev/null