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
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ Easily connect to the smart Issue Sentinel with this GitHub Action. It helps you

To use the Issue Sentinel, follow these steps:

1. Contact [email protected] to get the password for the Sentinel. We will assist you with onboarding and add your repository to the database.

1. Add the `ISSUE_SENTINEL_PASSWORD` as a secret to your repository. Go to `Settings > Secrets and variables > Actions > New repository secret`.
1. Contact [email protected] to get the permission for the Sentinel. We will assist you with onboarding and add your repository to the database.

1. Add the following workflow in your repository.

Expand All @@ -28,7 +26,6 @@ To use the Issue Sentinel, follow these steps:
- name: Run Issue Sentinel
uses: Azure/issue-sentinel@v1
with:
password: ${{secrets.ISSUE_SENTINEL_PASSWORD}}
enable-similar-issues-scanning: true # Scan similar issues in your repo, default: true
enable-security-issues-scanning: true # Scan security issues in your repo, default: false
```
Expand Down
3 changes: 0 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: 'Issue Sentinel'
description: 'Get similar issues by Issue Sentinel'
inputs:
password:
description: 'Password to access the Issue Sentinel'
required: true
github-token:
description: 'The GitHub token used to create an authenticated client'
default: ${{ github.token }}
Expand Down
22 changes: 10 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32641,7 +32641,6 @@ const PoweredBy = "\n_Powered by [issue-sentinel](https://github.com/Azure/issue
function main() {
return __awaiter(this, void 0, void 0, function* () {
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');
Expand All @@ -32658,23 +32657,23 @@ function main() {
core.debug(`Issue: ${JSON.stringify(issue)}`);
const { owner, repo } = context.repo;
if (enable_similar_issues_scanning === 'true') {
yield handleSimilarIssuesScanning(issue, owner, repo, password, token, botUrl);
yield handleSimilarIssuesScanning(issue, owner, repo, 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;
}
yield handleSecurityIssuesScanning(issue, owner, repo, password, token, botUrl);
yield handleSecurityIssuesScanning(issue, owner, repo, token, botUrl);
}
}
catch (error) {
core.setFailed(error.message);
}
});
}
function handleSimilarIssuesScanning(issue, owner, repo, password, token, botUrl) {
function handleSimilarIssuesScanning(issue, owner, repo, token, botUrl) {
return __awaiter(this, void 0, void 0, function* () {
const octokit = github.getOctokit(token);
const issueNumber = issue.number;
Expand All @@ -32685,28 +32684,27 @@ function handleSimilarIssuesScanning(issue, owner, repo, password, token, botUrl
if (if_closed) {
yield axios_1.default.post(botUrl + '/update_issue/', {
'raw': issue,
'password': password
'token': token
});
core.info('This issue was closed. Update it to issue sentinel.');
return;
}
const if_replied = (yield axios_1.default.post(botUrl + '/check_reply/', {
'repo': owner_repo,
'issue': issue.number,
'password': password
'token': token
})).data.result;
core.info('Check if this issue was already replied by the sentinel: ' + if_replied.toString());
if (if_replied) {
yield axios_1.default.post(botUrl + '/update_issue/', {
'raw': issue,
'password': password
'token': token
});
core.info('This issue was already replied by the sentinel. Update the edited content to sentinel and skip this issue.');
return;
}
const response = (yield axios_1.default.post(botUrl + '/search/', {
'raw': issue,
'password': password,
'verify': true,
'token': token //used for access issue comment to get possible solution
})).data;
Expand Down Expand Up @@ -32749,7 +32747,7 @@ function handleSimilarIssuesScanning(issue, owner, repo, password, token, botUrl
const if_replied_again = (yield axios_1.default.post(botUrl + '/check_reply/', {
'repo': owner_repo,
'issue': issue.number,
'password': password
'token': token
})).data.result;
if (if_replied_again) {
core.info('This issue was already replied by the sentinel during processing. Skip adding labels and comments.');
Expand Down Expand Up @@ -32777,12 +32775,12 @@ function handleSimilarIssuesScanning(issue, owner, repo, password, token, botUrl
yield axios_1.default.post(botUrl + '/add_reply/', {
'repo': owner_repo,
'issue': issue.number,
'password': password
'token': token
});
core.info('Save replied issue to issue sentinel.');
});
}
function handleSecurityIssuesScanning(issue, owner, repo, password, token, botUrl) {
function handleSecurityIssuesScanning(issue, owner, repo, token, botUrl) {
return __awaiter(this, void 0, void 0, function* () {
const octokit = github.getOctokit(token);
const issueNumber = issue.number;
Expand All @@ -32798,7 +32796,7 @@ function handleSecurityIssuesScanning(issue, owner, repo, password, token, botUr
}
const if_security = (yield axios_1.default.post(botUrl + '/security/', {
'raw': issue,
'password': password
'token': token
})).data.security;
core.info('Search the security issues by the issue sentinel successfully.');
core.debug(`Response: ${if_security}`);
Expand Down
22 changes: 10 additions & 12 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const PoweredBy = "\n_Powered by [issue-sentinel](https://github.com/Azure/issue

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');
Expand All @@ -25,7 +24,7 @@ async function main() {
const { owner, repo } = context.repo;

if (enable_similar_issues_scanning === 'true') {
await handleSimilarIssuesScanning(issue, owner, repo, password, token, botUrl);
await handleSimilarIssuesScanning(issue, owner, repo, token, botUrl);
}

if (enable_security_issues_scanning === 'true') {
Expand All @@ -34,15 +33,15 @@ async function main() {
core.info('Skip security issues scanning for edited and closed issue.');
return;
}
await handleSecurityIssuesScanning(issue, owner, repo, password, token, botUrl);
await handleSecurityIssuesScanning(issue, owner, repo, token, botUrl);
}
}
catch (error: any) {
core.setFailed(error.message);
}
}

async function handleSimilarIssuesScanning(issue: any, owner: string, repo: string, password: string, token: string, botUrl: string) {
async function handleSimilarIssuesScanning(issue: any, owner: string, repo: string, token: string, botUrl: string) {
const octokit = github.getOctokit(token);
const issueNumber = issue.number;
let owner_repo = `${owner}/${repo}`;
Expand All @@ -53,7 +52,7 @@ async function handleSimilarIssuesScanning(issue: any, owner: string, repo: stri
if (if_closed) {
await axios.post(botUrl + '/update_issue/', {
'raw': issue,
'password': password
'token': token
})
core.info('This issue was closed. Update it to issue sentinel.');
return;
Expand All @@ -62,22 +61,21 @@ async function handleSimilarIssuesScanning(issue: any, owner: string, repo: stri
const if_replied: boolean = (await axios.post(botUrl + '/check_reply/', {
'repo': owner_repo,
'issue': issue.number,
'password': password
'token': token
})).data.result;
core.info('Check if this issue was already replied by the sentinel: ' + if_replied.toString());

if (if_replied) {
await axios.post(botUrl + '/update_issue/', {
'raw': issue,
'password': password
'token': token
})
core.info('This issue was already replied by the sentinel. Update the edited content to sentinel and skip this issue.');
return;
}

const response = (await axios.post(botUrl + '/search/', {
'raw': issue,
'password': password,
'verify': true,
'token': token //used for access issue comment to get possible solution
})).data;
Expand Down Expand Up @@ -124,7 +122,7 @@ async function handleSimilarIssuesScanning(issue: any, owner: string, repo: stri
const if_replied_again: boolean = (await axios.post(botUrl + '/check_reply/', {
'repo': owner_repo,
'issue': issue.number,
'password': password
'token': token
})).data.result;

if (if_replied_again) {
Expand Down Expand Up @@ -156,12 +154,12 @@ async function handleSimilarIssuesScanning(issue: any, owner: string, repo: stri
await axios.post(botUrl + '/add_reply/', {
'repo': owner_repo,
'issue': issue.number,
'password': password
'token': token
});
core.info('Save replied issue to issue sentinel.');
}

async function handleSecurityIssuesScanning(issue: any, owner: string, repo: string, password: string, token: string, botUrl: string) {
async function handleSecurityIssuesScanning(issue: any, owner: string, repo: string, token: string, botUrl: string) {
const octokit = github.getOctokit(token);
const issueNumber = issue.number;
const { data: existedLabels } = await octokit.rest.issues.listLabelsOnIssue({
Expand All @@ -178,7 +176,7 @@ async function handleSecurityIssuesScanning(issue: any, owner: string, repo: str

const if_security = (await axios.post(botUrl + '/security/', {
'raw': issue,
'password': password
'token': token
})).data.security;
core.info('Search the security issues by the issue sentinel successfully.');
core.debug(`Response: ${if_security}`);
Expand Down