Update english-please workflow for workflow_dispatch (#285)

This commit is contained in:
Bhavya U 2024-07-29 10:53:15 -07:00 коммит произвёл GitHub
Родитель c6318998c5
Коммит 3a43e0b51b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 45 добавлений и 5 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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<void> {
// 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