Skip to content

Commit

Permalink
feat: upgrade workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Slava-Shchipunov committed Aug 13, 2024
1 parent 226ae60 commit 4505eff
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 64 deletions.
42 changes: 32 additions & 10 deletions .github/workflows/build-module.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/tets-script.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.idea/
node_modules/
results.json
44 changes: 26 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -60,25 +66,27 @@ async function getDetails(target, subtarget) {
}

async function main() {
const targets = await getTargets();
const results = [];
try {
const targets = await getTargets();
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({
tag: version,
target,
subtarget,
vermagic,
pkgarch,
});
for (const target of targets) {
const subtargets = await getSubtargets(target);
for (const subtarget of subtargets) {
const { vermagic, pkgarch } = await getDetails(target, subtarget);
jobConfig.push({
tag: version,
target,
subtarget,
vermagic,
pkgarch,
});
}
}
core.setOutput('job-config', JSON.stringify(jobConfig));
} catch (error) {
core.setFailed(error.message);
}

fs.writeFileSync('results.json', JSON.stringify(results, null, 2), 'utf-8');
console.log('Results written to results.json');
}

main().catch(console.error);
main();
60 changes: 60 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 4505eff

Please sign in to comment.