Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

action.cjs: catch raise eagerly #126

Merged
merged 1 commit into from
May 13, 2024
Merged
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
44 changes: 22 additions & 22 deletions action.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@ module.exports = async ({ github, context, inputs, actionPath }) => {
? await import(`${actionPath}/src/subtleSubmitReview.js`)
: await import(`${actionPath}/src/submitReview.js`)

const { default: getPatch } = (context.payload.pull_request && context.payload.pull_request.user.login === 'renovate[bot]') || context.actor === 'renovate[bot]'
? options.subtle_mode ? raise('subtle_mode enabled, this is not supported for renovate') : await import(`${actionPath}/src/getRenovatePatch.js`)
: (context.payload.pull_request && context.payload.pull_request.user.login === 'dependabot[bot]') || context.actor === 'dependabot[bot]'
? options.subtle_mode ? raise('subtle_mode enabled, this is not supported for dependabot') : await import(`${actionPath}/src/getDependabotPatch.js`)
: await import(`${actionPath}/src/getPatch.js`)

options.key = options.anthropic_api_key || options.openai_api_key
options.models = options.bedrock_aws_iam_role_arn
? options.bedrock_models
: options.anthropic_api_key
? options.anthropic_models
: options.openai_models

debug = options.debug ? (options.debug === 'true') : debug

if (debug) {
console.log(`Using options: ${JSON.stringify(options)}`)
console.log(`Using config: ${JSON.stringify(config)}`)
console.log(`Using properties: ${JSON.stringify(properties)}`)
console.log(`Using inputs: ${JSON.stringify(inputs)}`)
}

try {
const { default: getPatch } = (context.payload.pull_request && context.payload.pull_request.user.login === 'renovate[bot]') || context.actor === 'renovate[bot]'
? options.subtle_mode ? raise('subtle_mode enabled, this is not supported for renovate') : await import(`${actionPath}/src/getRenovatePatch.js`)
: (context.payload.pull_request && context.payload.pull_request.user.login === 'dependabot[bot]') || context.actor === 'dependabot[bot]'
? options.subtle_mode ? raise('subtle_mode enabled, this is not supported for dependabot') : await import(`${actionPath}/src/getDependabotPatch.js`)
: await import(`${actionPath}/src/getPatch.js`)

options.key = options.anthropic_api_key || options.openai_api_key
options.models = options.bedrock_aws_iam_role_arn
? options.bedrock_models
: options.anthropic_api_key
? options.anthropic_models
: options.openai_models

debug = options.debug ? (options.debug === 'true') : debug

if (debug) {
console.log(`Using options: ${JSON.stringify(options)}`)
console.log(`Using config: ${JSON.stringify(config)}`)
console.log(`Using properties: ${JSON.stringify(properties)}`)
console.log(`Using inputs: ${JSON.stringify(inputs)}`)
}

const patch = await getPatch({
owner: options.owner,
repo: options.repo,
Expand Down