Skip to content

Commit 5f49931

Browse files
committed
ci: create reusable workflow to list packages
Signed-off-by: CrazyMax <[email protected]>
1 parent fb4bcbd commit 5f49931

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

.github/workflows/.pkgs.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# reusable workflow
2+
name: .pkgs
3+
4+
on:
5+
workflow_call:
6+
outputs:
7+
list:
8+
description: List of packages as JSON array
9+
value: ${{ jobs.run.outputs.pkgs }}
10+
11+
jobs:
12+
run:
13+
runs-on: ubuntu-24.04
14+
outputs:
15+
pkgs: ${{ steps.set.outputs.pkgs }}
16+
steps:
17+
-
18+
name: Checkout
19+
uses: actions/checkout@v6
20+
-
21+
name: Set pkgs output
22+
id: set
23+
uses: actions/github-script@v8
24+
with:
25+
script: |
26+
const fs = require('fs');
27+
const path = require('path');
28+
const disabledPkgs = (process.env.DISABLED_PACKAGES || '').split(',').map(s => s.trim()).filter(Boolean);
29+
const pkgs = fs.readdirSync('./pkg', { withFileTypes: true }).filter(d => d.isDirectory()).map(d => d.name).filter(name => !disabledPkgs.includes(name));
30+
core.info(JSON.stringify(pkgs, null, 2));
31+
core.setOutput('pkgs', JSON.stringify(pkgs));

.github/workflows/nightly.yml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,17 @@ on:
1111
- cron: '0 1 * * 0'
1212

1313
jobs:
14-
prepare:
15-
runs-on: ubuntu-24.04
16-
outputs:
17-
pkgs: ${{ steps.matrix.outputs.pkgs }}
18-
steps:
19-
-
20-
name: Checkout
21-
uses: actions/checkout@v6
22-
-
23-
name: Matrix
24-
id: matrix
25-
uses: actions/github-script@v8
26-
with:
27-
script: |
28-
const fs = require('fs');
29-
const path = require('path');
30-
const disabledPkgs = (process.env.DISABLED_PACKAGES || '').split(',').map(s => s.trim()).filter(Boolean);
31-
const pkgs = fs.readdirSync('./pkg', { withFileTypes: true }).filter(d => d.isDirectory()).map(d => d.name).filter(name => !disabledPkgs.includes(name));
32-
core.info(JSON.stringify(pkgs, null, 2));
33-
core.setOutput('pkgs', JSON.stringify(pkgs));
14+
pkgs:
15+
uses: ./.github/workflows/.pkgs.yml
3416

3517
build:
3618
uses: ./.github/workflows/.build.yml
3719
needs:
38-
- prepare
20+
- pkgs
3921
strategy:
4022
fail-fast: false
4123
matrix:
42-
pkg: ${{ fromJson(needs.prepare.outputs.pkgs) }}
24+
pkg: ${{ fromJson(needs.pkgs.outputs.list) }}
4325
with:
4426
name: ${{ matrix.pkg }}
4527
release: pushonly

0 commit comments

Comments
 (0)