feat: upgrade workflow

This commit is contained in:
Slava-Shchipunov
2024-08-13 22:24:06 +07:00
parent 226ae606a8
commit 4505effac5
6 changed files with 119 additions and 64 deletions

View File

@@ -1,22 +1,44 @@
name: Create Release on Tag
# on: [workflow_dispatch]
# on:
# push:
# tags:
# - "v*.*.*"
on:
push:
tags:
- "v*.*.*"
jobs:
generate-config:
runs-on: ubuntu-latest
outputs:
job-config: ${{ steps.generate-config.outputs.job-config }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.16.0'
- name: Get OpenWRT version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Install dependencies
run: npm install
- name: Generate Job Config
id: generate-config
run: node index.js ${{ env.VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
name: "v${{ matrix.build_env.tag }} - ${{ matrix.build_env.pkgarch}} :: ${{ matrix.build_env.target}}/${{ matrix.build_env.subtarget}} build"
runs-on: ubuntu-latest
needs: generate-config
strategy:
matrix:
build_env:
- tag: "23.05.4"
pkgarch: aarch64_cortex-a53
target: mediatek
subtarget: filogic
vermagic: "03ba5b5fee47f2232a088e3cd9832aec"
build_env: ${{ fromJson(needs.generate-config.outputs.job-config) }}
steps:
- uses: actions/checkout@v4

View File

@@ -1,35 +0,0 @@
name: OpenWRT Data Fetch
on:
push:
tags:
- 'v*.*.*'
jobs:
fetch-data:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.16.0'
- name: Get OpenWRT version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Install dependencies
run: npm install
- name: Run script with version
run: node index.js ${{ env.VERSION }}
- name: Upload results.json
uses: actions/upload-artifact@v2
with:
name: results
path: results.json

1
.gitignore vendored
View File

@@ -1,3 +1,2 @@
.idea/
node_modules/
results.json

View File

@@ -1,8 +1,14 @@
const axios = require('axios');
const cheerio = require('cheerio');
const fs = require('fs');
const core = require('@actions/core');
const version = process.argv[2]; // Получение версии OpenWRT из аргумента командной строки
if (!version) {
core.setFailed('Version argument is required');
process.exit(1);
}
const url = `https://downloads.openwrt.org/releases/${version}/targets/`;
async function fetchHTML(url) {
@@ -60,14 +66,15 @@ async function getDetails(target, subtarget) {
}
async function main() {
try {
const targets = await getTargets();
const results = [];
const jobConfig = [];
for (const target of targets) {
const subtargets = await getSubtargets(target);
for (const subtarget of subtargets) {
const { vermagic, pkgarch } = await getDetails(target, subtarget);
results.push({
jobConfig.push({
tag: version,
target,
subtarget,
@@ -76,9 +83,10 @@ async function main() {
});
}
}
fs.writeFileSync('results.json', JSON.stringify(results, null, 2), 'utf-8');
console.log('Results written to results.json');
core.setOutput('job-config', JSON.stringify(jobConfig));
} catch (error) {
core.setFailed(error.message);
}
}
main().catch(console.error);
main();

60
package-lock.json generated
View File

@@ -9,10 +9,52 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.10.1",
"axios": "^1.3.1",
"cheerio": "^1.0.0"
}
},
"node_modules/@actions/core": {
"version": "1.10.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz",
"integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==",
"license": "MIT",
"dependencies": {
"@actions/http-client": "^2.0.1",
"uuid": "^8.3.2"
}
},
"node_modules/@actions/http-client": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.1.tgz",
"integrity": "sha512-KhC/cZsq7f8I4LfZSJKgCvEwfkE8o1538VoBeoGzokVLLnbFDEAdFD3UhoMklxo2un9NJVBdANOresx7vTHlHw==",
"license": "MIT",
"dependencies": {
"tunnel": "^0.0.6",
"undici": "^5.25.4"
}
},
"node_modules/@actions/http-client/node_modules/undici": {
"version": "5.28.4",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz",
"integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==",
"license": "MIT",
"dependencies": {
"@fastify/busboy": "^2.0.0"
},
"engines": {
"node": ">=14.0"
}
},
"node_modules/@fastify/busboy": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz",
"integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==",
"license": "MIT",
"engines": {
"node": ">=14"
}
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
@@ -354,6 +396,15 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
"license": "MIT",
"engines": {
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
}
},
"node_modules/undici": {
"version": "6.19.7",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.19.7.tgz",
@@ -363,6 +414,15 @@
"node": ">=18.17"
}
},
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"license": "MIT",
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/whatwg-encoding": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz",

View File

@@ -17,6 +17,7 @@
},
"homepage": "https://github.com/Slava-Shchipunov/awg-openwrt#readme",
"dependencies": {
"@actions/core": "^1.10.1",
"axios": "^1.3.1",
"cheerio": "^1.0.0"
}