feat: add manual start for build

This commit is contained in:
Slava-Shchipunov
2025-10-04 00:04:18 +07:00
parent e9dc49aeda
commit 55a2e3c3f0
2 changed files with 55 additions and 15 deletions

View File

@@ -9,6 +9,20 @@ on:
tag_name: tag_name:
required: true required: true
type: string type: string
workflow_dispatch:
inputs:
version:
description: 'OpenWRT version (e.g., 24.10.3)'
required: true
type: string
targets:
description: 'Targets (comma-separated, e.g., "stm32,ramips")'
required: true
type: string
subtargets:
description: 'Subtargets (comma-separated, e.g., "stm32mp1,mt7621")'
required: true
type: string
jobs: jobs:
generate-config: generate-config:
@@ -27,8 +41,12 @@ jobs:
- name: Get OpenWRT version from tag - name: Get OpenWRT version from tag
id: get_version id: get_version
run: | run: |
if [ "${{ github.event_name }}" == "workflow_call" ]; then if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "VERSION=${{ inputs.tag_name }}" >> $GITHUB_ENV echo "VERSION=${{ inputs.version }}" >> $GITHUB_ENV
echo "TARGETS=${{ inputs.targets }}" >> $GITHUB_ENV
echo "SUBTARGETS=${{ inputs.subtargets }}" >> $GITHUB_ENV
elif [ "${{ github.event_name }}" == "workflow_call" ]; then
VERSION="${{ inputs.tag_name }}"
echo "VERSION=${VERSION#v}" >> $GITHUB_ENV echo "VERSION=${VERSION#v}" >> $GITHUB_ENV
else else
echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
@@ -39,7 +57,7 @@ jobs:
- name: Generate Job Config - name: Generate Job Config
id: generate-config id: generate-config
run: node index.js ${{ env.VERSION }} run: node index.js ${{ env.VERSION }} "${{ env.TARGETS }}" "${{ env.SUBTARGETS }}"
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -3,16 +3,19 @@ const cheerio = require('cheerio');
const core = require('@actions/core'); const core = require('@actions/core');
const version = process.argv[2]; // Получение версии OpenWRT из аргумента командной строки const version = process.argv[2]; // Получение версии OpenWRT из аргумента командной строки
const filterTargetsStr = process.argv[3] || ''; // Фильтр по targets (опционально, через запятую)
const filterSubtargetsStr = process.argv[4] || ''; // Фильтр по subtargets (опционально, через запятую)
const SNAPSHOT_TARGETS_TO_BUILD = ['mediatek', 'ramips', 'x86', 'armsr']; // Преобразуем строки с запятыми в массивы
const SNAPSHOT_SUBTARGETS_TO_BUILD = ['filogic', 'mt7622', 'mt7623', 'mt7629', 'mt7620', 'mt7621', 'mt76x8', '64', 'generic', 'armv8']; const filterTargets = filterTargetsStr ? filterTargetsStr.split(',').map(t => t.trim()).filter(t => t) : [];
const filterSubtargets = filterSubtargetsStr ? filterSubtargetsStr.split(',').map(s => s.trim()).filter(s => s) : [];
if (!version) { if (!version) {
core.setFailed('Version argument is required'); core.setFailed('Version argument is required');
process.exit(1); process.exit(1);
} }
const url = version === 'SNAPSHOT' ? 'https://downloads.openwrt.org/snapshots/targets/' : `https://downloads.openwrt.org/releases/${version}/targets/`; const url = `https://downloads.openwrt.org/releases/${version}/targets/`;
async function fetchHTML(url) { async function fetchHTML(url) {
try { try {
@@ -74,19 +77,38 @@ async function main() {
const jobConfig = []; const jobConfig = [];
for (const target of targets) { for (const target of targets) {
// Пропускаем target, если указан массив фильтров и target не входит в него
if (filterTargets.length > 0 && !filterTargets.includes(target)) {
continue;
}
const subtargets = await getSubtargets(target); const subtargets = await getSubtargets(target);
for (const subtarget of subtargets) { for (const subtarget of subtargets) {
// Пропускаем subtarget, если указан массив фильтров и subtarget не входит в него
if (filterSubtargets.length > 0 && !filterSubtargets.includes(subtarget)) {
continue;
}
// Добавляем в конфигурацию только если:
// 1. Оба массива пустые (автоматическая сборка по тегу) - собираем всё
// 2. Оба массива НЕ пустые (ручной запуск) - target И subtarget должны быть в своих массивах
const isAutomatic = filterTargets.length === 0 && filterSubtargets.length === 0;
const isManualMatch = filterTargets.length > 0 && filterSubtargets.length > 0 &&
filterTargets.includes(target) && filterSubtargets.includes(subtarget);
if (!isAutomatic && !isManualMatch) {
continue;
}
const { vermagic, pkgarch } = await getDetails(target, subtarget); const { vermagic, pkgarch } = await getDetails(target, subtarget);
if (version !== 'SNAPSHOT' || (SNAPSHOT_SUBTARGETS_TO_BUILD.includes(subtarget) && SNAPSHOT_TARGETS_TO_BUILD.includes(target))) { jobConfig.push({
jobConfig.push({ tag: version,
tag: version, target,
target, subtarget,
subtarget, vermagic,
vermagic, pkgarch,
pkgarch, });
});
}
} }
} }