chore: Edit automated PR config (#519)

* Edit PR title/body, add $lib/data folder

* Remove unused scripts/updateStars.js

* Load json with import assertion
This commit is contained in:
Lachlan Collins
2023-12-18 10:59:20 +11:00
committed by GitHub
parent 77451078d7
commit c597e70e11
8 changed files with 14 additions and 136 deletions

View File

@@ -1,5 +1,8 @@
import core from '@actions/core';
import { readFileSync, writeFileSync } from 'node:fs';
import { writeFileSync } from 'node:fs';
import components from '../src/routes/components/components.json' assert { type: 'json' };
import templates from '../src/routes/templates/templates.json' assert { type: 'json' };
import tools from '../src/routes/tools/tools.json' assert { type: 'json' };
import { fetch } from 'undici';
const ghGraphQlUrl = 'https://api.github.com/graphql';
@@ -28,10 +31,6 @@ async function doGraphQlQuery(url, query, headers = {}) {
}
function gatherUrls() {
let components = JSON.parse(readFileSync('src/routes/components/components.json'));
let tools = JSON.parse(readFileSync('src/routes/tools/tools.json'));
let templates = JSON.parse(readFileSync('src/routes/templates/templates.json'));
return [
...components.map((component) => component.repository),
...tools.map((tool) => tool.repository),
@@ -179,7 +178,7 @@ async function main() {
0
)} stars)`
);
writeFileSync('src/lib/stars.json', JSON.stringify({ github, gitlab }));
writeFileSync('src/lib/data/stars.json', JSON.stringify({ github, gitlab }));
}
try {

View File

@@ -1,4 +1,4 @@
name: Fetch latest data
name: Update data
on:
schedule:
@@ -30,10 +30,10 @@ jobs:
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
commit-message: "(AUTO) Update stars"
title: "🤖 Update stars"
body: Update all stars count from Github and Gitlab
branch: ci-update-stars
add-paths: src/lib/stars.json
commit-message: "(AUTO) Update data"
title: "🤖 Update data"
body: Automatically fetch latest data from NPM, GitHub and GitLab
branch: ci-update-data
add-paths: src/lib/data/npm.json,src/lib/data/stars.json
delete-branch: true
token: ${{ secrets.GITHUB_TOKEN }}