-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (36 loc) · 1.25 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
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 deploymentId = core.getInput('deployment-id', {required: false}) || context.payload.deployment.id;
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: deploymentId,
state,
log_url: url,
target_url: url,
description,
};
console.log(params)
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();