diff --git a/english-please/action.yml b/english-please/action.yml index f647c8ff..7bbbe052 100644 --- a/english-please/action.yml +++ b/english-please/action.yml @@ -3,7 +3,24 @@ description: Identify and request translations for issues in languages besides e inputs: token: description: GitHub token with issue, comment, and label read/write permissions - default: ${{ github.token }} + app_id: + description: GitHub App ID + required: false + app_installation_id: + description: GitHub App Installation ID + required: false + app_private_key: + description: GitHub App Private Key + required: false + owner: + description: Repository owner + required: false + repo: + description: Repository name + required: false + issue_number: + description: Issue number + required: false nonEnglishLabel: description: Label to add when issues are not written in english required: true diff --git a/english-please/index.js b/english-please/index.js index 8b8e2098..5c84b377 100644 --- a/english-please/index.js +++ b/english-please/index.js @@ -1,8 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +const octokit_1 = require("../api/octokit"); +const Action_1 = require("../common/Action"); const utils_1 = require("../common/utils"); const EnglishPlease_1 = require("./EnglishPlease"); -const Action_1 = require("../common/Action"); const nonEnglishLabel = (0, utils_1.getRequiredInput)('nonEnglishLabel'); const needsMoreInfoLabel = (0, utils_1.getRequiredInput)('needsMoreInfoLabel'); const translatorRequestedLabelPrefix = (0, utils_1.getRequiredInput)('translatorRequestedLabelPrefix'); @@ -26,6 +27,16 @@ class EnglishPlease extends Action_1.Action { if (label == nonEnglishLabel) await this.doLanguageSpecific(issue); } + async onTriggered(_octokit) { + // This function is only called during a manual workspace dispatch event + // caused by a webhook, so we know to expect some inputs. + const auth = await this.getToken(); + const repo = (0, utils_1.getRequiredInput)('repo'); + const owner = (0, utils_1.getRequiredInput)('owner'); + const issue = JSON.parse((0, utils_1.getRequiredInput)('issue_number')); + const octokitIssue = new octokit_1.OctoKitIssue(auth, { owner, repo }, { number: issue.number }); + await this.doLanguageSpecific(octokitIssue); + } } new EnglishPlease().run(); // eslint-disable-line //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/english-please/index.ts b/english-please/index.ts index 1effecfa..056c6d16 100644 --- a/english-please/index.ts +++ b/english-please/index.ts @@ -1,7 +1,7 @@ -import { getRequiredInput } from '../common/utils'; -import { LanguageSpecificLabeler, EnglishPleaseLabler } from './EnglishPlease'; -import { OctoKitIssue } from '../api/octokit'; +import { OctoKit, OctoKitIssue } from '../api/octokit'; import { Action } from '../common/Action'; +import { getRequiredInput } from '../common/utils'; +import { EnglishPleaseLabler, LanguageSpecificLabeler } from './EnglishPlease'; const nonEnglishLabel = getRequiredInput('nonEnglishLabel'); const needsMoreInfoLabel = getRequiredInput('needsMoreInfoLabel'); @@ -33,6 +33,18 @@ class EnglishPlease extends Action { async onLabeled(issue: OctoKitIssue, label: string) { if (label == nonEnglishLabel) await this.doLanguageSpecific(issue); } + + async onTriggered(_octokit: OctoKit): Promise { + // This function is only called during a manual workspace dispatch event + // caused by a webhook, so we know to expect some inputs. + const auth = await this.getToken(); + const repo = getRequiredInput('repo'); + const owner = getRequiredInput('owner'); + const issue = JSON.parse(getRequiredInput('issue_number')); + + const octokitIssue = new OctoKitIssue(auth, { owner, repo }, { number: issue.number }); + await this.doLanguageSpecific(octokitIssue); + } } new EnglishPlease().run() // eslint-disable-line