Skip to content

Commit

Permalink
updated paths (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickLiffen committed May 30, 2022
1 parent c4ff8e5 commit dc3af5e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 22 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Goes and collects repositories that will have Code Scanning(CodeQL)/Secret Scann

- Collect the repositories where the primary language matches a specific value. For example, if you provide JavaScript, all repositories will be collected where the primary language is, Javascript.
- Collect the repositories to which a user has administrative access, or a GitHub App has access.
- Manually create `repos.json` or copy the `repos-sample.json` to `repos.json` in the bin folder.

If you select option 1, the script will return all repositories in the language you specify (which you have access to). The repositories collected from this script are then stored within a `repos.json` file. If you specify option 2, the script will return all repositories you are an administrator over. The third option is to define the `repos.json` manually. We don't recommend this, but it's possible. If you want to go down this path, first run one of the above options for collecting repository information automatically, look at the structure, and build your fine of the laid out format.

Expand Down
16 changes: 0 additions & 16 deletions bin/repos-sample.json

This file was deleted.

2 changes: 1 addition & 1 deletion src/enable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as dotenv from "dotenv";

dotenv.config({ path: __dirname + "/../../.env" });
dotenv.config({ path: __dirname + "/../.env" });

import { error } from "./utils/globals";

Expand Down
2 changes: 1 addition & 1 deletion src/getOrgs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as dotenv from "dotenv";

dotenv.config({ path: __dirname + "/../../.env" });
dotenv.config({ path: __dirname + "/../.env" });

import { error } from "./utils/globals";

Expand Down
2 changes: 1 addition & 1 deletion src/getRepos.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as dotenv from "dotenv";

dotenv.config({ path: __dirname + "/../../.env" });
dotenv.config({ path: __dirname + "/../.env" });

import { error } from "./utils/globals";

Expand Down
12 changes: 10 additions & 2 deletions src/utils/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { auth as generateAuth } from "./clients";
import { checkIfCodeQLHasAlreadyRanOnRepo } from "./checkCodeQLEnablement";

import { Octokit } from "./octokitTypes";
import { inform } from "./globals.js";
import { inform, reposFileLocation } from "./globals.js";
import { reposFile } from "../../types/common/index.js";

export const worker = async (): Promise<unknown> => {
Expand All @@ -31,7 +31,7 @@ export const worker = async (): Promise<unknown> => {

// Read the repos.json file and get the list of repos using fs.readFileSync, handle errors, if empty file return error, if file exists and is not empty JSON.parse it and return the list of repos
try {
file = readFileSync("../../bin/repos.json", "utf8");
file = readFileSync(reposFileLocation, "utf8");
if (file === "") {
throw new Error(
"We found your repos.json but it was empty, please run `yarn run getRepos` to collect the repos to run this script on."
Expand Down Expand Up @@ -102,7 +102,15 @@ export const worker = async (): Promise<unknown> => {
repo,
client
);

inform(
`Has ${owner}/${repo} had a CodeQL scan uploaded? ${codeQLAlreadyRan}`
);

if (!codeQLAlreadyRan) {
inform(
`Has ${owner}/${repo} hasn't had a CodeQL Scan, going to run CodeQL enablement`
);
const defaultBranch = await findDefulatBranch(owner, repo, client);
const defaultBranchSHA = await findDefulatBranchSHA(
defaultBranch,
Expand Down

0 comments on commit dc3af5e

Please sign in to comment.