-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (34 loc) · 1.38 KB
/
index.js
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
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const core = require('@actions/core');
const { context, GitHub } = require('@actions/github');
const fs = require('fs').promises;
const path = require('path');
const axios = require('axios');
import { Octokit, App } from "octokit";
const packagesEnginesPath = 'engines';
console.log('Starting.');
async function run() {
try {
const engineName = core.getInput('engineName');
const newTag = core.getInput('newTag');
const envJsonPath = path.join(packagesEnginesPath, engineName, 'env.json');
const envJsonStr = await fs.readFile(envJsonPath, 'utf-8');
const envData = JSON.parse(envJsonStr);
envData.COMMIT_TAG = newTag;
await fs.writeFile(envJsonPath, JSON.stringify(envData, null, 4));
const packagesJsonPath = path.join('metadata', 'packagessniper_v2.json');
const packagesJsonStr = await fs.readFile(packagesJsonPath, 'utf-8');
const packagesJson = JSON.parse(packagesJsonStr);
for(let engineData of packagesJson.engines) {
if(engineData.internal_engine_name === engineName) {
engineData.version = newTag;
}
}
await fs.writeFile(packagesJsonPath, JSON.stringify(packagesJson, null, 4));
}
catch (error) {
core.setFailed(error.message);
}
}
run();