-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
51 lines (43 loc) · 1.63 KB
/
index.js
File metadata and controls
51 lines (43 loc) · 1.63 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require('dotenv').config();
const Gardener = require("./gardener");
const GitHubClient = require("./githubClient");
(async () => {
try {
// Validate required environment variables
const requiredEnvVars = ['GITHUB_TOKEN', 'OWNER', 'REPO', 'APP_NAME'];
const missingVars = requiredEnvVars.filter(varName => !process.env[varName]);
if (missingVars.length > 0) {
console.error('❌ Missing required environment variables:', missingVars.join(', '));
console.error('Please set them in your .env file');
process.exit(1);
}
const github_token = process.env.GITHUB_TOKEN;
const owner = process.env.OWNER;
const repo = process.env.REPO;
const app_name = process.env.APP_NAME;
const branch = process.env.BRANCH || 'master';
const debug = process.env.DEBUG === 'gardener' || process.env.DEBUG === '*';
console.log(`🌱 Starting gardener for ${owner}/${repo} (branch: ${branch})...`);
// Create GitHub API client
const githubClient = new GitHubClient({
token: github_token,
appName: app_name,
debug
});
// Create gardener with injected client
const gardener = new Gardener({
githubClient,
owner,
repo,
branch
});
await gardener.run();
console.log('✅ Gardener completed successfully!');
} catch (error) {
console.error('❌ Gardener failed:', error.message);
if (process.env.DEBUG) {
console.error(error.stack);
}
process.exit(1);
}
})();