Skip to content

Commit 8efec3b

Browse files
committed
Add action
1 parent c9dd6c1 commit 8efec3b

7 files changed

Lines changed: 89 additions & 34 deletions

File tree

.github/workflows/blank.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: quote_generator
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 0 * * *"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-node@v1
15+
with:
16+
node-version: 12.16.1
17+
- run: npm ci
18+
- name: Generate quote
19+
run: npm run generate
20+
- name: Update README.md
21+
run: |
22+
git config --global user.email "hoangnn93@gmail.com"
23+
git config --global user.name "codeaholicguy"
24+
git add .
25+
git commit -m "Updated README.md"
26+
git push

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
_**Ideas don't get smaller when they're shared, they get bigger.**_
22

3-
Seth Godin
3+
Seth Godin

index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const axios = require("axios");
2+
const fs = require("fs");
3+
4+
const getQuote = async () => {
5+
try {
6+
const { data } = await axios.get(
7+
"https://gist.githubusercontent.com/codeaholicguy/be3c884ed8b2f49bf30f06555d022915/raw/79c57ecc2a256e3a3d02ac4676f77643f6f2529d/quotes.json"
8+
);
9+
const quote = data.contents.quotes[0].quote;
10+
const author = data.contents.quotes[0].author;
11+
12+
return {
13+
quote,
14+
author,
15+
};
16+
} catch (err) {
17+
return {};
18+
}
19+
};
20+
21+
const generate = async () => {
22+
const { quote, author } = await getQuote();
23+
24+
if (!quote) return;
25+
26+
fs.writeFileSync("README.md", `_**${quote}**_\n\n${author}`);
27+
};
28+
29+
generate();

package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "codeaholicguy",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"scripts": {
6+
"generate": "node index.js"
7+
},
8+
"dependencies": {
9+
"axios": "^0.20.0"
10+
}
11+
}

0 commit comments

Comments
 (0)