forked from farmersdog/clubhouse-workflow-action
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
38 lines (35 loc) · 1.07 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 github = require('@actions/github');
const core = require('@actions/core');
const ch = require('./src/clubhouse');
async function run() {
try {
const { payload, eventName } = github.context;
let updatedStories;
if (eventName === "release") {
const { body, html_url } = payload.release;
const addReleaseInfo = (core.getInput('addReleaseInfo') === 'true');
updatedStories = await ch.releaseStories(
body,
core.getInput('endStateName'),
html_url,
addReleaseInfo
);
} else if (eventName === "pull_request") {
const { title, body } = payload.pull_request;
const { ref } = payload.pull_request.head;
const content = `${title} ${body} ${ref}`;
updatedStories = await ch.transitionStories(
content,
core.getInput('endStateName')
);
} else {
throw new Error("Invalid event type");
}
core.setOutput(updatedStories);
console.log(`Updated Stories: \n \n${updatedStories.join(' \n')}`);
}
catch (error) {
core.setFailed(error.message);
}
}
run();