-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
35 lines (30 loc) · 1.1 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
const core = require('@actions/core');
const github = require('@actions/github');
const buildFeedbackMessage = require('./feedbackMessage');
const runStylelint = require('./runStylelint');
const runNpm = require('./runNpm');
const run = async () => {
try {
const root = process.env.GITHUB_WORKSPACE || process.cwd();
const token = core.getInput('token', { required: true });
const client = github.getOctokit(token);
const { owner, repo } = github.context.issue;
const npmStatus = runNpm(root);
const { status: stylelintStatus, outcomes: stylelintOutcomes } = runStylelint(root);
const status = npmStatus + stylelintStatus;
const feedbackMessage = buildFeedbackMessage(stylelintOutcomes, root);
console.log('Exit code:', status);
console.log('All errors:', stylelintOutcomes);
console.log('Feedback message:\n', feedbackMessage);
await client.issues.createComment({
owner,
repo,
issue_number: process.env.INPUT_PR_NUMBER,
body: feedbackMessage,
});
process.exit(status);
} catch (error) {
core.setFailed(error.message);
}
};
run();