Skip to content

Commit

Permalink
Update english-please workflow for workflow_dispatch (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavyaus authored Jul 29, 2024
1 parent c631899 commit 3a43e0b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
19 changes: 18 additions & 1 deletion english-please/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion english-please/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions english-please/index.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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

0 comments on commit 3a43e0b

Please sign in to comment.