in src/main.ts [7:43]
async function main() {
try {
const password = core.getInput('password');
//TODO: use github token for authentication
const token = core.getInput('github-token', { required: true });
const enable_similar_issues_scanning = core.getInput('enable-similar-issues-scanning');
const enable_security_issues_scanning = core.getInput('enable-security-issues-scanning');
if (enable_similar_issues_scanning !== 'true' && enable_security_issues_scanning !== 'true') {
throw new Error('Invalid input! Both similar issues scanning and security issues scanning are disabled. Please enable at least one of them.');
}
const botUrl = 'https://similar-bot-prod.calmhill-ec497646.eastus.azurecontainerapps.io';
const context = github.context;
if (!context.payload.issue) {
throw new Error("No issue found in the context payload. Please check your workflow trigger is 'issues'");
}
const issue = context.payload.issue;
core.debug(`Issue: ${JSON.stringify(issue)}`);
const { owner, repo } = context.repo;
if (enable_similar_issues_scanning === 'true') {
await handleSimilarIssuesScanning(issue, owner, repo, password, token, botUrl);
}
if (enable_security_issues_scanning === 'true') {
core.debug(`Issue trigger: ${context.payload.action}`);
if (context.payload.action !== 'opened') {
core.info('Skip security issues scanning for edited and closed issue.');
return;
}
await handleSecurityIssuesScanning(issue, owner, repo, password, token, botUrl);
}
}
catch (error: any) {
core.setFailed(error.message);
}
}