-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (37 loc) · 1.36 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
const core = require('@actions/core');
const github = require('@actions/github');
const {myError} = require('./utils/config');
const {gitAction} = require('./utils/git');
const {formatJS, formatPython} = require('./utils/formatters');
const mainFunc = async () => {
core.info('Taking variables...');
const token = core.getInput('gitHubToken', {required: true});
core.info('GitHub token was taken.');
const pythonFlag = core.getBooleanInput('python', {required: false});
core.info('Python flag was taken.');
const javascriptFlag = core.getBooleanInput('javascript', {
required: false,
});
core.info('JavaScript token was taken.');
const projectFolder = core.getInput('projectFolder') || '.';
core.info(`Project folder values is "${projectFolder}".`);
const payload = github.context.payload;
if (pythonFlag) {
core.info('Start formatting Python files...');
await formatPython(projectFolder);
core.info('Formatting is over.');
} else core.info('Python formatting is skipped.');
if (javascriptFlag) {
core.info('Start formatting JavaScript files...');
await formatJS(projectFolder);
core.info('Formatting is over.');
} else core.info('JavaScript formatting is skipped.');
core.info('Commit changes...');
await gitAction(payload, token);
};
try {
mainFunc();
} catch (error) {
core.info(myError);
core.setFailed(error.message);
}