-
Notifications
You must be signed in to change notification settings - Fork 9
69 lines (57 loc) · 1.94 KB
/
test.yml
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Combine JSON Files
on:
push:
paths:
- 'domains/*.json'
branches:
- main
workflow_dispatch:
jobs:
combine_json:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm --version
- name: Combine JSON files
run: |
const fs = require('fs');
const path = require('path');
const dirPath = path.join(__dirname, 'domains');
const outputPath = path.join(__dirname, 'index.json');
const combinedData = [];
fs.readdirSync(dirPath).forEach(file => {
if (file.endsWith('.json')) {
const data = JSON.parse(fs.readFileSync(path.join(dirPath, file), 'utf8'));
const domain = file.replace('.json', '.is-truly-a.pro');
const entry = {
domain,
owner: {
username: data.owner.username || null,
email: data.owner.email || null,
discord: data.owner.discord || null
}
};
// Remove empty fields
entry.owner = Object.fromEntries(
Object.entries(entry.owner).filter(([_, v]) => v != null)
);
combinedData.push(entry);
}
});
fs.writeFileSync(outputPath, JSON.stringify(combinedData, null, 2));
- name: Push to API repository
uses: cpina/github-action-push-to-another-repository@main
with:
source-directory: './'
destination-github-username: 'is-truly-a-pro'
destination-repository-name: 'api'
target-branch: 'main'
commit-message: 'Update index.json with combined domains'
env:
API_TOKEN_GITHUB: ${{ secrets.GH_API_TOKEN }}