Skip to content

Commit

Permalink
updater action
Browse files Browse the repository at this point in the history
  • Loading branch information
radoslavirha committed Jan 21, 2025
1 parent 729bbd8 commit 7dba03f
Show file tree
Hide file tree
Showing 13 changed files with 1,870 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .addons.yml → .addons.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
channel: stable
addons:
laskakit-data-feeder:
repository: radoslavirha/ha-addons
target: addons/laskakit-data-feeder
image: radoslavirha/ha-addon-laskakit-data-feeder-{arch}
image: radoslavirha/ha-addon-laskakit-data-feeder-{arch}
19 changes: 19 additions & 0 deletions .github/actions/repository-updater/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Radoslav's Home Assistant Add-on Repository Updater
description: Tool for updating Home Assistant Add-on repository.

inputs:
TOKEN:
description: GitHub token that is allowed to write/commit to the target repo
required: true
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
19 changes: 19 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: CI

# yamllint disable-line rule:truthy
on:
push:
workflow_dispatch:

jobs:
lint-yaml:
name: YAML lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run YAML lint
uses: frenck/[email protected]
with:
strict: true
38 changes: 23 additions & 15 deletions .github/workflows/repository-updater.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
---
name: Repository Update

# yamllint disable-line rule:truthy
on:
workflow_dispatch:
inputs:
ADDON:
description: Addon name
required: true
default: laskakit-data-feeder
type: string
FORCE:
description: Whether to update all add-ons
required: false
default: false
type: boolean
repository_dispatch:
types: ["update"]

jobs:
updater:
name: Running updater for ${{ github.event.client_payload.addon }}
name: Running updater for ${{ github.event.client_payload.addon || github.event.inputs.ADDON }}
runs-on: ubuntu-latest
steps:
- name: Running updater for ${{ github.event.client_payload.addon }}
run: echo ${{ github.event.client_payload.addon }}
# - name: 🚀 Run Repository Updater
# uses: hassio-addons/repository-updater@v1
# with:
# # addon: ${{ github.event.client_payload.addon }}
# addon: laskakit-data-feeder
# repository: ${{ github.repository }}
# token: ${{ secrets.UPDATER_TOKEN }}

# workflows:
# uses: hassio-addons/workflows/.github/workflows/repository-updater.yaml@main
# secrets:
# UPDATER_TOKEN: ${{ secrets.UPDATER_TOKEN }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Running updater for ${{ github.event.client_payload.addon || github.event.inputs.ADDON }}
run: echo ${{ github.event.client_payload.addon || github.event.inputs.ADDON }}
- name: Running updater for ${{ github.event.client_payload.addon || github.event.inputs.ADDON }}
uses: ./.github/actions/repository-updater
with:
TOKEN: ${{ secrets.UPDATER_TOKEN }}
ADDON: ${{ github.event.client_payload.addon || github.event.inputs.ADDON }}
FORCE: ${{ github.event.inputs.FORCE }}
9 changes: 9 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
extends: default

ignore:
- action/pnpm-lock.yaml

rules:
line-length:
max: 130
2 changes: 2 additions & 0 deletions action/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
21 changes: 21 additions & 0 deletions action/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"sourceMaps": false,
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
},
"target": "es2022",
"externalHelpers": true,
"keepClassNames": true,
"transform": {
"useDefineForClassFields": false,
"legacyDecorator": true,
"decoratorMetadata": true
}
},
"module": {
"type": "es6"
}
}
11 changes: 11 additions & 0 deletions action/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:22-slim

RUN corepack enable pnpm

COPY . .

RUN pnpm install --prod --frozen-lockfile && \
pnpm build && \
chmod a+x ./entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
4 changes: 4 additions & 0 deletions action/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
ls action
# action is directory where the action code is present
exec pnpm -C action start
23 changes: 23 additions & 0 deletions action/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "action",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "swc src --out-dir dist -s --strip-leading-paths",
"start": "cross-env NODE_ENV=production node --import @swc-node/register/esm-register dist/index.js"
},
"dependencies": {
"@actions/core": "^1.11.1",
"@actions/github": "^6.0.0",
"@swc-node/register": "^1.10.9",
"@swc/cli": "^0.6.0",
"@swc/core": "^1.10.8",
"@swc/helpers": "^0.5.15",
"cross-env": "^7.0.3"
},
"engines": {
"node": ">= 20.18.1",
"pnpm": ">= 9.14.4"
}
}
Loading

0 comments on commit 7dba03f

Please sign in to comment.