mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 14:24:13 +08:00
fix: use proper type guards instead of manual property checks
Address review feedback by using isEntityContext() type guard instead of checking 'isPR' in context manually. This provides better type safety and uses the existing type guard infrastructure.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as core from "@actions/core";
|
||||
import { GITHUB_API_URL, GITHUB_SERVER_URL } from "../github/api/config";
|
||||
import type { GitHubContext } from "../github/context";
|
||||
import { isEntityContext } from "../github/context";
|
||||
import { Octokit } from "@octokit/rest";
|
||||
|
||||
type PrepareConfigParams = {
|
||||
@@ -115,7 +116,7 @@ export async function prepareMcpConfig(
|
||||
const hasActionsReadPermission =
|
||||
context.inputs.additionalPermissions.get("actions") === "read";
|
||||
|
||||
if ("isPR" in context && context.isPR && hasActionsReadPermission) {
|
||||
if (isEntityContext(context) && context.isPR && hasActionsReadPermission) {
|
||||
// Verify the token actually has actions:read permission
|
||||
const actuallyHasPermission = await checkActionsReadPermission(
|
||||
process.env.ACTIONS_TOKEN || "",
|
||||
@@ -141,10 +142,9 @@ export async function prepareMcpConfig(
|
||||
GITHUB_TOKEN: process.env.ACTIONS_TOKEN,
|
||||
REPO_OWNER: owner,
|
||||
REPO_NAME: repo,
|
||||
PR_NUMBER:
|
||||
"entityNumber" in context
|
||||
? context.entityNumber?.toString() || ""
|
||||
: "",
|
||||
PR_NUMBER: isEntityContext(context)
|
||||
? context.entityNumber?.toString() || ""
|
||||
: "",
|
||||
RUNNER_TEMP: process.env.RUNNER_TEMP || "/tmp",
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user