Add GitHub Action support

This commit is contained in:
Franck Nijhof 2021-01-12 21:01:50 +01:00
parent 6030501397
commit ccddcfe4f4
No known key found for this signature in database
GPG key ID: D62583BA8AB11CA3
3 changed files with 61 additions and 0 deletions

27
action.yaml Normal file
View file

@ -0,0 +1,27 @@
---
name: "Community Home Assistant Add-ons Repository Updater"
description: Tool for updating Home Assistant Add-on repositories.
author: frenck
branding:
color: red
icon: thumbs-up
inputs:
token:
description: GitHub token that is allowed to write/commit to the target repo
required: true
repository:
description: The add-on repository to update (e.g., frenck/repository)
required: false
addon:
description: Slug of the add-on to update the repository for
required: false
force:
description: Force repository update, even if no changes are detected
default: "false"
required: false
runs:
using: "docker"
image: "action/Dockerfile"

12
action/Dockerfile Normal file
View file

@ -0,0 +1,12 @@
FROM python:3.9-alpine
RUN \
apk add --no-cache \
git=2.26.2-r0 \
\
&& pip3 install \
repository-updater==0.6.0
COPY lint.py /lint.py
ENTRYPOINT ["python3", "/lint.py"]

22
action/entrypoint.sh Normal file
View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
declare -a options
options+=(--token "${INPUT_TOKEN:-}")
if [[ -n "${INPUT_ADDON:-}" ]]; then
options+=(--repository "${INPUT_ADDON}")
else
options+=(--repository "${GITHUB_REPOSITORY}")
fi
[[ -n "${INPUT_ADDON:-}" ]] \
&& options+=(--addon "${INPUT_ADDON}")
[[ "${INPUT_FORCE,,}" = "true" ]] \
&& options+=(--force)
# Output version
repository-updater --version
# Update!
exec repository-updater "${options[@]}"