Skip to content

Commit f40071c

Browse files
Skip legacy action on github_app repos
1 parent f0aac1c commit f40071c

2 files changed

Lines changed: 44 additions & 4 deletions

File tree

src/api/client.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ interface ClientOptions {
1717
baseUrl: string;
1818
}
1919

20+
export interface RepositoryIntegrationModeResponse {
21+
repository_id: string | null;
22+
found: boolean;
23+
integration_mode: 'legacy_action' | 'github_app';
24+
}
25+
2026
export class AsymptoteClient {
2127
private apiKey: string;
2228
private baseUrl: string;
@@ -146,6 +152,17 @@ export class AsymptoteClient {
146152
}
147153
}
148154

155+
async getRepositoryIntegrationMode(
156+
owner: string,
157+
name: string
158+
): Promise<RepositoryIntegrationModeResponse> {
159+
const params = new URLSearchParams({ owner, name });
160+
return this.request<RepositoryIntegrationModeResponse>(
161+
'GET',
162+
`/api/repository-integration-mode?${params.toString()}`
163+
);
164+
}
165+
149166
private sleep(ms: number): Promise<void> {
150167
return new Promise((resolve) => setTimeout(resolve, ms));
151168
}

src/index.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ async function run(): Promise<void> {
1616
core.info('Asymptote Security Scan starting...');
1717
core.debug(`API URL: ${config.apiUrl}`);
1818

19+
const client = new AsymptoteClient({
20+
apiKey: config.apiKey,
21+
baseUrl: config.apiUrl,
22+
});
23+
1924
// 2. Verify PR context
2025
if (github.context.eventName !== 'pull_request') {
2126
core.setFailed(
@@ -34,6 +39,28 @@ async function run(): Promise<void> {
3439
}
3540
const octokit = github.getOctokit(githubToken);
3641

42+
try {
43+
const integration = await client.getRepositoryIntegrationMode(
44+
github.context.repo.owner,
45+
github.context.repo.repo
46+
);
47+
if (integration.integration_mode === 'github_app') {
48+
core.info(
49+
'Repository is configured for GitHub App PR reviews; exiting legacy action without posting comments or checks.'
50+
);
51+
core.setOutput('decision', 'allow');
52+
core.setOutput('total_violations', 0);
53+
core.setOutput('critical_count', 0);
54+
core.setOutput('high_count', 0);
55+
core.setOutput('medium_count', 0);
56+
return;
57+
}
58+
} catch (error) {
59+
core.warning(
60+
`Failed to look up repository integration mode; continuing with legacy action path. ${error instanceof Error ? error.message : String(error)}`
61+
);
62+
}
63+
3764
// 4. Get PR diff (incremental on synchronize, full otherwise)
3865
const action = github.context.payload.action;
3966
const before = github.context.payload.before;
@@ -140,10 +167,6 @@ async function run(): Promise<void> {
140167

141168
// 5. Call Asymptote API
142169
core.info('Submitting diff for evaluation...');
143-
const client = new AsymptoteClient({
144-
apiKey: config.apiKey,
145-
baseUrl: config.apiUrl,
146-
});
147170

148171
let result;
149172
try {

0 commit comments

Comments
 (0)