Skip to content

Commit 0e902fb

Browse files
committed
added auto config file creation
1 parent a7f6bc0 commit 0e902fb

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ jobs:
4747
- name: Upload build artifacts
4848
uses: actions/upload-artifact@v4
4949
with:
50-
path: ./app.tar.gz
50+
name: app.tar.gz
51+
path: .
5152
retention-days: 1 # Set to 1 day for temporary storage
5253

5354
release:
@@ -61,6 +62,7 @@ jobs:
6162
- name: Download build artifacts
6263
uses: actions/download-artifact@v4
6364
with:
65+
name: app.tar.gz
6466
path: ./app.tar.gz
6567

6668
- name: Create GitHub Release

server/utils/config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface ConfigLike {
1010
export class ConfigHandler {
1111

1212
private static readonly configFilePath = process.env.CONFIG_FILE_PATH || './config/config.json';
13+
private static readonly sampleConfigFilePath = './config/config.sample.json';
1314

1415
private static config: ConfigLike | null = null;
1516

@@ -23,6 +24,17 @@ export class ConfigHandler {
2324
if (this.config) return this.config;
2425

2526
try {
27+
28+
if (!fs.existsSync(this.configFilePath)) {
29+
// If config file does not exist, create it from sample
30+
if (fs.existsSync(this.sampleConfigFilePath)) {
31+
fs.copyFileSync(this.sampleConfigFilePath, this.configFilePath);
32+
} else {
33+
console.error("Could not find config file or sample config file.");
34+
process.exit(1);
35+
}
36+
}
37+
2638
// Load the config from config file is not already loaded
2739
const configFile = fs.readFileSync(this.configFilePath, 'utf-8');
2840
this.config = JSON.parse(configFile) as ConfigLike;

0 commit comments

Comments
 (0)