Skip to content

Commit 235d25a

Browse files
added new stuff
1 parent 86dfa7d commit 235d25a

2 files changed

Lines changed: 45 additions & 8 deletions

File tree

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ inputs:
66
required: true
77
default: 'World'
88
outputs:
9-
time: # id of output
10-
description: 'The time we greeted you'
9+
info: # id of output
10+
description: 'A JSON String of the post info'
1111
runs:
1212
using: 'node12'
1313
main: 'index.js'

index.js

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,50 @@ const github = require('@actions/github');
33

44
try {
55
// `who-to-greet` input defined in action metadata file
6-
const nameToGreet = core.getInput('who-to-greet');
7-
console.log(`Hello ${nameToGreet}!`);
8-
const time = (new Date()).toTimeString();
9-
core.setOutput("time", time);
6+
// const nameToGreet = core.getInput('who-to-greet');
7+
// console.log(`Hello ${nameToGreet}!`);
8+
// const time = (new Date()).toTimeString();
9+
// core.setOutput("time", time);
1010
// Get the JSON webhook payload for the event that triggered the workflow
11-
const payload = JSON.stringify(github.context.payload, undefined, 2)
12-
console.log(`The event payload: ${payload}`);
11+
// const payload = JSON.stringify(github.context.payload, undefined, 2)
12+
// console.log(`The event payload: ${payload}`);
13+
14+
15+
16+
let event = github.context.eventName;
17+
18+
if (event !== "push") {
19+
// error how to core
20+
core.setFailed("This action only works on push events");
21+
return;
22+
}
23+
24+
let ref = github.context.ref;
25+
let branch = res.replace(/^refs\/(heads|tags)\//, '');
26+
27+
let username = github.context.actor;
28+
let repo = github.context.repo.repo;
29+
30+
31+
let commitMessage = github.context.payload.commits[0].message;
32+
// explode commit message on new line
33+
let commitMessageArray = commitMessage.split("\n\n");
34+
35+
let title = commitMessageArray[0];
36+
let body = commitMessageArray[1];
37+
38+
let info = {
39+
"title": title,
40+
"body": body,
41+
"username": username,
42+
"repo": repo,
43+
"branch": branch,
44+
"timestamp": new Date().toTimeString()
45+
};
46+
47+
core.setOutput("info", JSON.stringify(info));
48+
console.log( JSON.stringify(info));
49+
1350
} catch (error) {
1451
core.setFailed(error.message);
1552
}

0 commit comments

Comments
 (0)