-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
30 lines (23 loc) · 1.14 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
const core = require('@actions/core');
const github = require('@actions/github');
const fs = require( "fs" );
const path = require( "path" );
try {
console.log( "Scanning Social Shareboard entries in ", core.getInput('dir_name') );
let shareboardFull = fs.readdirSync( path.join( core.getInput('dir_name'), "notes" ) )
.filter( file => path.extname( file ).toLowerCase() === ".md" )
.filter( file => file !== "sample.md" )
.map( file => fs.readFileSync( path.join( core.getInput('dir_name'), "notes", file ) ) )
.join( "\n---\n" );
console.log( "tracking_file: ", core.getInput('tracking_file'));
console.log( "Shareboard contents:\n");
console.log(shareboardFull);
if(core.getInput('tracking_file')) {
console.log("Writing random number to tracking file in case no other changes")
fs.writeFileSync( core.getInput('tracking_file'), "Random Number: " + Math.random() );
}
console.log("Writing to the markdown file in the talk folder: ", core.getInput('shareboard_file'))
fs.writeFileSync( core.getInput('shareboard_file'), shareboardFull );
} catch (error) {
core.setFailed(error.message);
}