Skip to content

Commit

Permalink
support issue_comment for prs
Browse files Browse the repository at this point in the history
  • Loading branch information
allisonport-db committed Dec 2, 2021
1 parent be10897 commit 2af3cf0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/generate-project-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* GraphQl query to get project and column information
*
* @param {string} url - Issue or Pull request url
* @param {string} eventName - The current event name
* @param {string} is_pr - Whether the event is a Pull Request (false if it's an Issue)
* @param {string} project - The project to find
*/
const projectQuery = (url, eventName, project) =>
const projectQuery = (url, is_pr, project) =>
`query {
resource( url: "${url}" ) {
... on ${eventName.startsWith('issue') ? 'Issue' : 'PullRequest'} {
... on ${!is_pr ? 'Issue' : 'PullRequest'} {
projectCards {
nodes {
id
Expand Down
5 changes: 3 additions & 2 deletions src/get-action-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ const getActionData = githubContext => {
eventName,
action: payload.action,
nodeId: githubData.node_id,
url: githubData.html_url
};
url: githubData.html_url,
is_pr: !!payload.pull_request || !!payload.issue.pull_request
}
};

module.exports = getActionData;
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ const generateMutationQuery = require('./generate-mutation-query');
const action = core.getInput('action') || 'update';

// Get data from the current action
const {eventName, nodeId, url} = getActionData(github.context);
const {eventName, nodeId, url, is_pr} = getActionData(github.context);

// Create a method to query GitHub
const octokit = new github.GitHub(token);

// Get the column ID from searching for the project and card Id if it exists
const projectQuery = generateProjectQuery(url, eventName, project);
const projectQuery = generateProjectQuery(url, is_pr, project);

core.debug(projectQuery);

Expand Down

0 comments on commit 2af3cf0

Please sign in to comment.