Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions actions/setup/js/validate_secrets.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,15 @@ async function testNotionAPI(token) {
}
}

/**
* Check if running in a forked repository
* @param {Object|null|undefined} payload - GitHub context payload
* @returns {boolean}
*/
function isForkRepository(payload) {
return payload?.repository?.fork === true;
}

/**
* Format status emoji
* @param {string} status
Expand Down Expand Up @@ -615,6 +624,10 @@ async function main() {
try {
core.info("Starting secret validation...");

if (isForkRepository(context.payload)) {
core.warning(`⚠️ This repository is a fork. Secrets from the parent repository are not inherited. You must configure each secret listed below directly in your fork's repository settings.`);
}

const owner = context.repo.owner;
const repo = context.repo.repo;

Expand Down Expand Up @@ -749,6 +762,7 @@ async function main() {

module.exports = {
main,
isForkRepository,
testGitHubRESTAPI,
testGitHubGraphQLAPI,
testCopilotCLI,
Expand Down
32 changes: 31 additions & 1 deletion actions/setup/js/validate_secrets.test.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check

import { describe, it, expect } from "vitest";
import { testGitHubRESTAPI, testGitHubGraphQLAPI, testCopilotCLI, testAnthropicAPI, testOpenAIAPI, testBraveSearchAPI, testNotionAPI, generateMarkdownReport } from "./validate_secrets.cjs";
import { testGitHubRESTAPI, testGitHubGraphQLAPI, testCopilotCLI, testAnthropicAPI, testOpenAIAPI, testBraveSearchAPI, testNotionAPI, generateMarkdownReport, isForkRepository } from "./validate_secrets.cjs";

describe("validate_secrets", () => {
describe("testGitHubRESTAPI", () => {
Expand Down Expand Up @@ -211,4 +211,34 @@ describe("validate_secrets", () => {
expect(report).toContain("GitHub GraphQL API");
});
});

describe("isForkRepository", () => {
it("should return true when repository.fork is true", () => {
const payload = { repository: { fork: true } };
expect(isForkRepository(payload)).toBe(true);
});

it("should return false when repository.fork is false", () => {
const payload = { repository: { fork: false } };
expect(isForkRepository(payload)).toBe(false);
});

it("should return false when repository.fork is absent", () => {
const payload = { repository: {} };
expect(isForkRepository(payload)).toBe(false);
});

it("should return false when repository is absent", () => {
const payload = {};
expect(isForkRepository(payload)).toBe(false);
});

it("should return false when payload is null", () => {
expect(isForkRepository(null)).toBe(false);
});

it("should return false when payload is undefined", () => {
expect(isForkRepository(undefined)).toBe(false);
});
});
});