From 6a63531f21158e10f01d0af0f1330de2231fe278 Mon Sep 17 00:00:00 2001 From: ai-dev Date: Fri, 1 Nov 2024 17:25:52 +0100 Subject: [PATCH] add act runner addon --- gitea_act_runner/Dockerfile | 39 ++++++++++++++++++++++++++++++++++++ gitea_act_runner/config.yaml | 34 +++++++++++++++++++++++++++++++ gitea_act_runner/run.sh | 15 ++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 gitea_act_runner/Dockerfile create mode 100644 gitea_act_runner/config.yaml create mode 100644 gitea_act_runner/run.sh diff --git a/gitea_act_runner/Dockerfile b/gitea_act_runner/Dockerfile new file mode 100644 index 0000000..08680bc --- /dev/null +++ b/gitea_act_runner/Dockerfile @@ -0,0 +1,39 @@ +ARG BUILD_FROM +FROM $BUILD_FROM + +ENV LANG C.UTF-8 + +# Setup base system +ARG \ + BUILD_ARCH + +# 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 + +# Install Ansible via pip +RUN pip3 install --no-cache-dir ansible + +# Optional: Additional steps for SSH/GitHub authentication or configuration + +# Copy your add-on scripts and configuration files +COPY run.sh /run.sh +RUN chmod +x /run.sh + +CMD [ "/run.sh" ] + +# Labels +LABEL \ + io.hass.name="Act Runner" \ + io.hass.description="Gitea act runner" \ + io.hass.arch="${BUILD_ARCH}" \ + io.hass.type="addon" \ + io.hass.version="v0.0.0"\ + maintainer="feres mezned" \ + org.opencontainers.image.title="Act runner" \ + org.opencontainers.image.description="Gitea act runner" \ + org.opencontainers.image.vendor="Home Assistant Local Add-ons" \ + org.opencontainers.image.authors="Feres MEZNED" \ + org.opencontainers.image.licenses="NO" \ + org.opencontainers.image.url="https://mezgit.duckdns.org/mezned/HAddons" \ + org.opencontainers.image.source="https://mezgit.duckdns.org/mezned/HAddons/gitea_act_runner" diff --git a/gitea_act_runner/config.yaml b/gitea_act_runner/config.yaml new file mode 100644 index 0000000..901529d --- /dev/null +++ b/gitea_act_runner/config.yaml @@ -0,0 +1,34 @@ +name: "Act Runner and Ansible Add-on" +version: "1.0.0" +slug: "act_runner_ansible" +description: "Home Assistant add-on that runs Act runner with Gitea integration." +arch: + - aarch64 + - amd64 + - armhf + - armv7 + - i386 +startup: "application" +boot: "auto" +options: + gitea_url: "https://your-gitea-instance.com" + gitea_token: "your_token" + repository: "user/repository" + act_runner_options: "--secret-file my.secrets --env-file my.env" +schema: + gitea_url: + type: string + description: "The URL of the Gitea server to register the Act runner." + required: true + gitea_token: + type: string + description: "The token for authenticating with Gitea." + required: true + repository: + type: string + description: "The Gitea repository to register the runner with, in 'user/repository' format." + required: true + act_runner_options: + type: string + description: "Additional options to pass to Act runner." + required: false \ No newline at end of file diff --git a/gitea_act_runner/run.sh b/gitea_act_runner/run.sh new file mode 100644 index 0000000..a7932de --- /dev/null +++ b/gitea_act_runner/run.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# 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') + +# 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"] }' + +# Run Act with specified options +act $ACT_OPTIONS