-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
26 lines (18 loc) · 765 Bytes
/
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
const core = require("@actions/core");
const fs = require("fs").promises;
const axios = require("axios");
const readme_path = core.getInput('readme_path') || "README.md";
(async () => {
try {
const { data } = await axios.get(`https://api.npoint.io/97e73eca87e1ee7e3e10`);
let quote = `<!-- start quote -->\n`;
let qotd = data.contents.quotes[0].quote;
quote = quote.concat(`💬 Quote of the Day: "${qotd}"\n<!-- end quote -->`);
const currentText = await fs.readFile(readme_path, "utf8");
const quoteSection = /<!-- start quote -->[\s\S]*<!-- end quote -->/g;
const newText = currentText.replace(quoteSection, quote);
await fs.writeFile(readme_path, newText);
} catch (error) {
console.log(error.message);
}
})();