generated from darsan-in/Template-repo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "[email protected]" }, | ||
}); | ||
} | ||
|
||
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(); |