Skip to content

Commit 2336ee6

Browse files
author
Italo Sousa
committed
feat: Add action to update site data
1 parent 7a9298c commit 2336ee6

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

.github/workflows/site_data.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Update Site Data
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
generate_data:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
with:
13+
fetch-depth: 0
14+
- name: Setup Node
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: '16'
18+
- name: Install Dependencies
19+
run: yarn --frozen-lockfile
20+
- name: Update data
21+
run: yarn run update-site-data
22+
- name: Commit changes
23+
uses: stefanzweifel/git-auto-commit-action@v4
24+
with:
25+
commit_message: 'chore: Update site data'
26+
file_pattern: static/data/**

scripts/updateSiteData.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ const filterRepos = (repos) => {
7676

7777
const writeData = (name, data) => {
7878
console.log("Writting data");
79-
fs.writeFileSync(
80-
path.join(__dirname, "../static", "data", `${name}.json`),
81-
JSON.stringify(data)
82-
);
79+
const pathDir = path.join(__dirname, "../static", "data");
80+
if (!fs.existsSync(pathDir)) {
81+
fs.mkdirSync(pathDir);
82+
}
83+
fs.writeFileSync(path.join(pathDir, `${name}.json`), JSON.stringify(data));
8384
};
8485

8586
async function run() {

0 commit comments

Comments
 (0)