fix: reworking files

This commit is contained in:
GitHub Actions
2022-05-11 13:09:38 +02:00
parent a141d23972
commit 19c4c8f761
5 changed files with 9550 additions and 201 deletions

View File

@@ -1,15 +1,11 @@
import fs from 'fs';
import ejs from 'ejs';
import * as core from '@actions/core';
import { remark } from 'remark';
import toc from 'remark-toc';
import git from './git';
export const REPO_USERNAME = process.env.GITHUB_REPOSITORY?.split('/')[0];
export const API_STARRED_URL = `${process.env.GITHUB_API_URL}/users/${REPO_USERNAME}/starred`;
const fsp = fs.promises;
export async function renderer(
data: { [key: string]: any },
templateString: string
@@ -38,22 +34,3 @@ export function generateMd(data: string): Promise<string> {
}
export const MARKDOWN_FILENAME: string = core.getInput('output-filename');
type File = {
filename: string;
data: string;
};
export async function pushNewFiles(files: File[] = []): Promise<any> {
if (!files.length) return;
await git.pull();
await Promise.all(
files.map(({ filename, data }) => fsp.writeFile(filename, data))
);
await git.add(files.map(({ filename }) => filename));
await git.commit(`chore(updates): updated entries in files`);
await git.push();
}