mirror of
https://github.com/gangoke/kobrax-lan-hass-component.git
synced 2026-08-11 16:47:52 +00:00
70 lines
2.1 KiB
YAML
70 lines
2.1 KiB
YAML
name: Build Kobrax Card
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
paths:
|
|
- custom_components/kobrax_lan/frontend_panel/**
|
|
- .github/workflows/build-card.yml
|
|
|
|
jobs:
|
|
build-card:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: custom_components/kobrax_lan/frontend_panel
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: custom_components/kobrax_lan/frontend_panel/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build card
|
|
run: npm run build_card:quick
|
|
|
|
- name: Upload card artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: kobrax-lan-card
|
|
path: custom_components/kobrax_lan/frontend_panel/dist/kobrax-lan-card.js
|
|
if-no-files-found: error
|
|
|
|
- name: Dispatch card repo sync
|
|
if: ${{ secrets.CARD_REPO_DISPATCH_TOKEN != '' }}
|
|
uses: actions/github-script@v7
|
|
env:
|
|
CARD_REPO_DISPATCH_TOKEN: ${{ secrets.CARD_REPO_DISPATCH_TOKEN }}
|
|
CARD_REPO_OWNER: ${{ github.repository_owner }}
|
|
CARD_REPO_NAME: kobrax-lan-hass-card
|
|
with:
|
|
script: |
|
|
const token = process.env.CARD_REPO_DISPATCH_TOKEN;
|
|
const owner = process.env.CARD_REPO_OWNER;
|
|
const repo = process.env.CARD_REPO_NAME;
|
|
|
|
if (!token) {
|
|
core.info('CARD_REPO_DISPATCH_TOKEN is not set; skipping card repo dispatch.');
|
|
return;
|
|
}
|
|
|
|
const octokit = github.getOctokit(token);
|
|
await octokit.request('POST /repos/{owner}/{repo}/dispatches', {
|
|
owner,
|
|
repo,
|
|
event_type: 'sync-card',
|
|
client_payload: {
|
|
source_repository: `${context.repo.owner}/${context.repo.repo}`,
|
|
run_id: context.runId,
|
|
artifact_name: 'kobrax-lan-card',
|
|
source_branch: context.ref.replace('refs/heads/', ''),
|
|
},
|
|
});
|