Skip to content

Commit

Permalink
create_file,js updated
Browse files Browse the repository at this point in the history
darsan-in committed Aug 11, 2024
1 parent 84f1765 commit e6bc8ad
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions create_file.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { Octokit } from "octokit";
const { listRepoRemote } = require("./list_repo");
const { readFileSync } = require("fs");

const octakit = new Octokit({ auth: process.env.GITHUB_TOKEN });
async function addFile(owner, repoName, destPath, content, message) {
const { Octokit } = await import("@octokit/rest");

const {
repos: { createOrUpdateFileContents },
} = octakit.rest;
const octakit = new Octokit({ auth: process.env.GITHUB_TOKEN });

const {
repos: { createOrUpdateFileContents },
} = octakit.rest;

export default function addFile(owner, repoName, destPath, content, message) {
createOrUpdateFileContents({
repo: repoName,
owner: owner,
@@ -17,3 +20,22 @@ export default function addFile(owner, repoName, destPath, content, message) {
author: { name: "DARSAN", email: "hello@darsan.in" },
});
}

async function main() {
const groupedRepolists = await listRepoRemote();

const content = readFileSync("consistent-desc.yaml", {
encoding: "base64",
});

const destPath = ".github/workflows/consistent-desc.yaml";
const commitMsg = "End-User meta WF added";

Object.keys(groupedRepolists).forEach((username) => {
groupedRepolists[username].forEach((repoName) => {
addFile(username, repoName, destPath, content, commitMsg);
});
});
}

main();

0 comments on commit e6bc8ad

Please sign in to comment.