This commit is contained in:
ai-dev 2024-11-01 21:29:05 +01:00
parent d7aa564769
commit 3201e0b9e6
6 changed files with 41 additions and 33 deletions

View File

@ -4,19 +4,6 @@ FROM ${BUILD_FROM}
ENV LANG C.UTF-8 ENV LANG C.UTF-8
# Copy root filesystem
COPY rootfs /
# Install necessary dependencies
RUN apk add --no-cache git docker-cli python3 py3-pip && \
curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | bash
RUN adduser -s /bin/false -D -H actrunner
# Create a directory for the virtual environment and install Ansible inside it
RUN python3 -m venv /opt/ansible-venv && \
/opt/ansible-venv/bin/pip install --no-cache-dir ansible
RUN chmod +x /etc/s6-overlay/s6-rc.d/actrunner/*
# Build arguments # Build arguments
ARG BUILD_ARCH ARG BUILD_ARCH
ARG BUILD_DATE ARG BUILD_DATE
@ -25,6 +12,24 @@ ARG BUILD_NAME
ARG BUILD_REF ARG BUILD_REF
ARG BUILD_REPOSITORY ARG BUILD_REPOSITORY
ARG BUILD_VERSION ARG BUILD_VERSION
ARG ACT_RUNNER_VERSION="0.2.11"
# Copy root filesystem
COPY rootfs /
# Install necessary dependencies
RUN apk add --no-cache git docker-cli python3 py3-pip
# Download and rename the act_runner binary
RUN curl -L -o /usr/local/bin/act_runner https://gitea.com/gitea/act_runner/releases/download/v${ACT_RUNNER_VERSION}/act_runner-${ACT_RUNNER_VERSION}-linux-${BUILD_ARCH} && \
chmod +x /usr/local/bin/act_runner
# Create a directory for the virtual environment and install Ansible inside it
RUN python3 -m venv /opt/ansible-venv && \
/opt/ansible-venv/bin/pip install --no-cache-dir ansible
RUN chmod +x /etc/s6-overlay/s6-rc.d/actrunner/*
RUN chmod +x /etc/s6-overlay/s6-rc.d/init-actrunner/*
# Labels # Labels
LABEL \ LABEL \

View File

@ -4,7 +4,6 @@ version: "1.0.0"
slug: "act_runner_ansible" slug: "act_runner_ansible"
description: "Home Assistant add-on that runs Act runner with Gitea integration." description: "Home Assistant add-on that runs Act runner with Gitea integration."
url: https://mezgit.duckdns.org/mezned/HAddons/gitea_act_runner url: https://mezgit.duckdns.org/mezned/HAddons/gitea_act_runner
codenotary: codenotary@feres.dev
init: false init: false
arch: arch:
- aarch64 - aarch64
@ -13,12 +12,12 @@ arch:
options: options:
gitea_url: "https://your-gitea-instance.com" gitea_url: "https://your-gitea-instance.com"
gitea_token: "your_token" gitea_token: "your_token"
repository: "user/repository" runner_name: "name"
act_runner_options: none runner_label: "label"
log_level: "info" log_level: "info"
schema: schema:
gitea_url: str gitea_url: str
gitea_token: str gitea_token: str
repository: str runner_name: str
act_runner_options: str? runner_label: str
log_level: list(trace|debug|info|notice|warning|error|fatal)? log_level: list(trace|debug|info|notice|warning|error|fatal)?

View File

@ -32,19 +32,5 @@ export "LOG_LEVEL=${log_level}"
# Activate the Ansible virtual environment # Activate the Ansible virtual environment
source /opt/ansible-venv/bin/activate source /opt/ansible-venv/bin/activate
# Load configuration from Home Assistant
GITEA_URL=$(bashio::config 'gitea_url')
GITEA_TOKEN=$(bashio::config 'gitea_token')
REPOSITORY=$(bashio::config 'repository')
ACT_OPTIONS=$(bashio::config 'act_runner_options')
# Activate the Ansible virtual environment
source /opt/ansible-venv/bin/activate
# Register Act runner with Gitea (if needed)
curl -X POST "$GITEA_URL/api/v1/repos/$REPOSITORY/actions/runners" \
-H "Authorization: token $GITEA_TOKEN" \
-d '{ "name": "Act Runner", "labels": ["self-hosted"] }'
bashio::log.info "Handing over control to actrunner..." bashio::log.info "Handing over control to actrunner..."
exec /usr/local/bin/act $ACT_OPTIONS exec exec /usr/local/bin/act_runner daemon

View File

@ -0,0 +1,16 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: Example
# Example init script, runs before any other service
# ==============================================================================
bashio::log.info "register act_runner !"
# Load configuration from Home Assistant
GITEA_URL=$(bashio::config 'gitea_url')
GITEA_TOKEN=$(bashio::config 'gitea_token')
RUNNER_NAME=$(bashio::config 'runner_name')
RUNNER_LABEL=$(bashio::config 'runner_label')
exec /usr/local/bin/act_runner register --no-interactive --instance ${GITEA_URL} --token ${GITEA_TOKEN} --name ${RUNNER_NAME} --labels ${RUNNER_LABEL}

View File

@ -0,0 +1 @@
oneshot

View File

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-example/run