Skip to content

Commit 6813f0d

Browse files
committed
reduce matrix
1 parent ad449bf commit 6813f0d

3 files changed

Lines changed: 29 additions & 59 deletions

File tree

.github/workflows/renew-all.yml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,15 @@ jobs:
1212
runs-on: ubuntu-latest
1313
env:
1414
DEPLOY_DIR: ${{ matrix.deploydir }}
15-
DOT_CONFIG: ${{ matrix.dotconfig }}
1615
strategy:
17-
fail-fast: false
16+
fail-fast: true
1817
matrix:
1918
deploydir:
2019
- preset-lede
2120
- preset-openwrt
2221
- preset-immortalwrt
2322
- preset-lienol-openwrt
2423
- preset-x-wrt
25-
dotconfig:
26-
- 1.config
27-
- 2.config
28-
include:
29-
- deploydir: preset-openwrt
30-
dotconfig: multi-common.config
31-
- deploydir: preset-openwrt
32-
dotconfig: multi-mini.config
3324
steps:
3425

3526
- uses: actions/checkout@v4
@@ -38,27 +29,30 @@ jobs:
3829
env:
3930
RENEW_PY: extra-files/renew.py
4031
run: |
41-
chmod +x $RENEW_PY
42-
$RENEW_PY
32+
DOT_CONFIG_ARRAY=(1.config 2.config)
33+
if [ "$DEPLOY_DIR" = "preset-openwrt" ]; then
34+
DOT_CONFIG_ARRAY+=(multi-common.config multi-mini.config)
35+
fi
36+
for DOT_CONFIG in "${DOT_CONFIG_ARRAY[@]}"; do
37+
chmod +x $RENEW_PY
38+
$RENEW_PY
39+
done
4340
4441
- uses: actions/upload-artifact@v4
4542
with:
4643
name: ${{ env.DEPLOY_DIR }}
4744
path: ${{ env.DEPLOY_DIR }}
4845

4946
commit:
50-
if: always()
5147
needs: renew
5248
runs-on: ubuntu-latest
5349
steps:
5450

5551
- uses: actions/checkout@v4
5652

57-
- uses: actions/download-artifact@v3
58-
59-
- uses: actions/download-artifact@v3
60-
61-
- uses: geekyeggo/delete-artifact@v2
53+
- uses: actions/download-artifact@v4
54+
55+
- uses: geekyeggo/delete-artifact@v5
6256
with:
6357
name: '*'
6458

.github/workflows/renew.yml

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -19,55 +19,28 @@ permissions:
1919

2020
jobs:
2121

22-
set-matrix:
23-
runs-on: ubuntu-latest
24-
outputs:
25-
dotconfig: ${{ steps.set-matrix.outputs.dotconfig }}
26-
deploydir: ${{ steps.set-matrix.outputs.deploydir }}
27-
steps:
28-
29-
- uses: actions/checkout@v4
30-
31-
- id: set-matrix
32-
uses: actions/github-script@v6
33-
with:
34-
script: |
35-
const fs = require('fs');
36-
let dotconfig = [];
37-
let cLs = "${{ inputs.dotconfig }}".replaceAll(' ', '').split(',');
38-
let deploydir = "${{ inputs.deploydir }}".trim();
39-
if (deploydir.endsWith('/')) deploydir = deploydir.slice(0, -1);
40-
for (i=0; i<cLs.length; i++) {
41-
try {
42-
fs.accessSync(deploydir + '/' + cLs[i]);
43-
dotconfig.push(cLs[i]);
44-
}
45-
catch (err) {
46-
console.log(cLs[i] + ' does not exist!');
47-
}
48-
}
49-
core.setOutput("dotconfig", JSON.stringify(dotconfig));
50-
core.setOutput("deploydir", deploydir);
51-
5222
renew:
53-
needs: set-matrix
5423
runs-on: ubuntu-latest
55-
env:
56-
DEPLOY_DIR: ${{ needs.set-matrix.outputs.deploydir }}
57-
DOT_CONFIG: ${{ matrix.dotconfig }}
58-
strategy:
59-
matrix:
60-
dotconfig: ${{ fromJSON(needs.set-matrix.outputs.dotconfig) }}
6124
steps:
6225

6326
- uses: actions/checkout@v4
6427

6528
- name: Carry out
6629
env:
6730
RENEW_PY: extra-files/renew.py
31+
DEPLOY_DIR: ${{ inputs.deploydir }}
32+
DOT_CONFIG_IN: ${{ inputs.dotconfig }}
6833
run: |
69-
chmod +x $RENEW_PY
70-
$RENEW_PY
34+
if [ ! -d "$DEPLOY_DIR" ]; then
35+
echo "Directory $DEPLOY_DIR does not exist!"
36+
exit 1
37+
fi
38+
39+
DOT_CONFIG_ARRAY=($(echo $DOT_CONFIG_IN | tr -d ' ' | tr ',' '\n'))
40+
for DOT_CONFIG in "${DOT_CONFIG_ARRAY[@]}"; do
41+
chmod +x $RENEW_PY
42+
$RENEW_PY
43+
done
7144

7245
- uses: actions/upload-artifact@v4
7346
with:
@@ -81,9 +54,9 @@ jobs:
8154

8255
- uses: actions/checkout@v4
8356

84-
- uses: actions/download-artifact@v3
57+
- uses: actions/download-artifact@v4
8558

86-
- uses: geekyeggo/delete-artifact@v2
59+
- uses: geekyeggo/delete-artifact@v5
8760
with:
8861
name: '*'
8962

extra-files/tools/routine_cmd.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import subprocess
23

34

@@ -12,5 +13,7 @@ def gen_dot_config(clone: str, config: str):
1213
f'mv -f {config} .config && make defconfig',
1314
f'cp -f .config {config}'
1415
]
16+
if os.path.isdir('feeds'):
17+
commands[:] = commands[2:]
1518
for cmd in commands:
1619
subprocess.run(cmd, shell=True)

0 commit comments

Comments
 (0)