-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.js
38 lines (34 loc) · 1.13 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
const core = require("@actions/core");
const github = require("@actions/github");
async function run() {
try {
const context = github.context;
const defaultUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/commit/${context.sha}/checks`;
const token = core.getInput("token", {required: true});
const state = core.getInput("state", {required: true});
const url = core.getInput("log-url", {required: false}) || defaultUrl;
const description = core.getInput("description", {required: false});
const env = core.getInput("environment", {required: false});
const envUrl = core.getInput("environment-url", {required: false});
const client = new github.GitHub(token);
const params = {
...context.repo,
deployment_id: context.payload.deployment.id,
state,
log_url: url,
target_url: url,
description,
};
if (env) {
params.environment = env;
}
if (envUrl) {
params.environment_url = envUrl;
}
await client.repos.createDeploymentStatus(params);
} catch (error) {
core.error(error);
core.setFailed(error.message);
}
}
run();