Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support issue_comment for pull requests #79

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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} payload - The event payload
* @param {string} project - The project to find
*/
const projectQuery = (url, eventName, project) =>
const projectQuery = (url, payload, project) =>
`query {
resource( url: "${url}" ) {
... on ${eventName.startsWith('issue') ? 'Issue' : 'PullRequest'} {
... on ${!payload.pull_request && !payload.issue.pull_request ? 'Issue' : 'PullRequest'} {
projectCards {
nodes {
id
Expand Down
6 changes: 1 addition & 5 deletions src/get-action-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@ const getActionData = githubContext => {
throw new Error(`Only pull requests, reviews, issues, or comments allowed. Received:\n${eventName}`);
}

const githubData = eventName === 'issues' || eventName === 'issue_comment' ?
payload.issue :
payload.pull_request;
const githubData = payload.issue || payload.pull_request

return {
eventName,
action: payload.action,
nodeId: githubData.node_id,
url: githubData.html_url
};
Expand Down
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 {nodeId, url} = 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, github.context.payload, project);

core.debug(projectQuery);

Expand Down