diff --git a/README.md b/README.md index 1ee53d7..38b0975 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ octodemo/template-demo-github-user-search | --------------------------| -------- | ------------------------------- | | `github_token` | `true` | PAT(Personal Access Token) for accessing the issues on the repository, defaults to `${{ github.token }}`. | | `issue_id` | `true` | The id of the issue to load the content from.| +| `repository` | `false` | The repository where the issue lives. Defaults to the current repository.| | `separator` | `false` | The separator between the fields defaults to `###` which is markdown h3 which GitHub is currently defaulting to | | `label_marker_start` | `true` | The characters to match for the beginning of a label | | `label_marker_end` | `true` | The characters to match for the ending of a label | @@ -48,6 +49,7 @@ steps: uses: peter-murray/issue-forms-body-parser@v1.1.0 with: issue_id: ${{ github.event.issue.number }} + repository: octokit/rest.js separator: '###' label_marker_start: '>>' label_marker_end: '<<' diff --git a/action.yml b/action.yml index 974f492..cc8cdac 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,11 @@ inputs: default: ${{ github.token }} required: true + repository: + description: The GitHub repository where the issue lives + default: ${{ github.repository }} + required: true + issue_id: description: The id of the issue to use to extract a payload from the body required: true diff --git a/dist/index.js b/dist/index.js index b29b831..0c99adb 100644 --- a/dist/index.js +++ b/dist/index.js @@ -21,13 +21,14 @@ async function run() { , parserSeparator = getRequiredInputValue('separator') , parserMarkerStart = getRequiredInputValue('label_marker_start') , parserMarkerEnd = getRequiredInputValue('label_marker_end') + , repository = getRequiredInputValue('repository') ; const issueUtil = new IssueUtil(githubToken) , parser = new Parser(parserSeparator, parserMarkerStart, parserMarkerEnd) ; - const issueBody = await issueUtil.getIssueBody(issueId); + const issueBody = await issueUtil.getIssueBody(issueId, repository); const parsed = parser.parse(issueBody); if (parsed !== undefined) { @@ -5885,9 +5886,11 @@ module.exports = class IssueUtil { this.octokit = github.getOctokit(token); } - getIssueBody(id) { + getIssueBody(id, repository) { + const [owner, repo] = repository.split('/'); + return this.octokit.issues.get({ - ...github.context.repo, + ...{owner, repo}, issue_number: id }).then(result => { if (result.status !== 200) { @@ -5900,6 +5903,7 @@ module.exports = class IssueUtil { } } + /***/ }), /***/ 657: diff --git a/index.js b/index.js index 1e6a95b..e490a16 100644 --- a/index.js +++ b/index.js @@ -14,13 +14,14 @@ async function run() { , parserSeparator = getRequiredInputValue('separator') , parserMarkerStart = getRequiredInputValue('label_marker_start') , parserMarkerEnd = getRequiredInputValue('label_marker_end') + , repository = getRequiredInputValue('repository') ; const issueUtil = new IssueUtil(githubToken) , parser = new Parser(parserSeparator, parserMarkerStart, parserMarkerEnd) ; - const issueBody = await issueUtil.getIssueBody(issueId); + const issueBody = await issueUtil.getIssueBody(issueId, repository); const parsed = parser.parse(issueBody); if (parsed !== undefined) { diff --git a/src/IssueUtil.js b/src/IssueUtil.js index c2dff90..c4338c6 100644 --- a/src/IssueUtil.js +++ b/src/IssueUtil.js @@ -9,9 +9,11 @@ module.exports = class IssueUtil { this.octokit = github.getOctokit(token); } - getIssueBody(id) { + getIssueBody(id, repository) { + const [owner, repo] = repository.split('/'); + return this.octokit.issues.get({ - ...github.context.repo, + ...{owner, repo}, issue_number: id }).then(result => { if (result.status !== 200) { @@ -22,4 +24,4 @@ module.exports = class IssueUtil { throw err; }); } -} \ No newline at end of file +}