Skip to content

Commit

Permalink
chore: make EXCLUDED_FILES optional and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
obeys committed Dec 13, 2024
1 parent 78c59b5 commit 573872f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
19 changes: 6 additions & 13 deletions .github/empty-string-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,17 @@ const token = process.env.GITHUB_TOKEN;
const [owner, repo] = process.env.GITHUB_REPOSITORY?.split("/") || [];
const pullNumber = process.env.GITHUB_PR_NUMBER || process.env.PULL_REQUEST_NUMBER || "0";
const baseRef = process.env.GITHUB_BASE_REF;
const excludeEnv = process.env.EXCLUDED_FILES;
const excludedFiles: string[] = [];
const excludedFiles: string[] = process.env.EXCLUDED_FILES
? process.env.EXCLUDED_FILES.split("\n")
.map((file) => file.trim())
.filter(Boolean)
: [];

if (!token || !owner || !repo || pullNumber === "0" || !baseRef || excludeEnv === undefined) {
if (!token || !owner || !repo || pullNumber === "0" || !baseRef) {
core.setFailed("Missing required environment variables.");
process.exit(1);
}

// Only process excludeEnv if it has content
if (excludeEnv.length > 0) {
excludedFiles.push(
...excludeEnv
.split("\n")
.map((file) => file.trim())
.filter(Boolean)
);
}

const octokit = new Octokit({ auth: token });
const git = simpleGit();

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/no-empty-strings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_BASE_REF: ${{ github.base_ref }}
EXCLUDED_FILES:

0 comments on commit 573872f

Please sign in to comment.