-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathaction.yaml
More file actions
36 lines (32 loc) · 1.17 KB
/
action.yaml
File metadata and controls
36 lines (32 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
name: App Inventory
description: Return items from the apps directory in a JSON array
outputs:
apps:
description: App Inventory
value: ${{ steps.inventory.outputs.apps }}
runs:
using: composite
steps:
- name: App Inventory
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: inventory
with:
script: |
const fs = require('fs');
const path = require('path');
function scanDirectory(dirPath) {
try {
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
const folderNames = entries
.filter((entry) => entry.isDirectory())
.map((entry) => entry.name);
return folderNames;
} catch (error) {
console.error(`Error reading directory ${dirPath}:`, error.message);
return [];
}
}
const apps = scanDirectory(path.resolve(__dirname, 'apps')).sort();
core.setOutput('apps', JSON.stringify(apps));