Skip to content

Commit 188755f

Browse files
refactor args
1 parent 2af3cf0 commit 188755f

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

Diff for: dist/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/generate-project-query.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* GraphQl query to get project and column information
33
*
44
* @param {string} url - Issue or Pull request url
5-
* @param {string} is_pr - Whether the event is a Pull Request (false if it's an Issue)
5+
* @param {string} payload - The event payload
66
* @param {string} project - The project to find
77
*/
8-
const projectQuery = (url, is_pr, project) =>
8+
const projectQuery = (url, payload, project) =>
99
`query {
1010
resource( url: "${url}" ) {
11-
... on ${!is_pr ? 'Issue' : 'PullRequest'} {
11+
... on ${!payload.pull_request && !payload.issue.pull_request ? 'Issue' : 'PullRequest'} {
1212
projectCards {
1313
nodes {
1414
id

Diff for: src/get-action-data.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,12 @@ const getActionData = githubContext => {
1717
throw new Error(`Only pull requests, reviews, issues, or comments allowed. Received:\n${eventName}`);
1818
}
1919

20-
const githubData = eventName === 'issues' || eventName === 'issue_comment' ?
21-
payload.issue :
22-
payload.pull_request;
20+
const githubData = payload.issue || payload.pull_request
2321

2422
return {
25-
eventName,
26-
action: payload.action,
2723
nodeId: githubData.node_id,
28-
url: githubData.html_url,
29-
is_pr: !!payload.pull_request || !!payload.issue.pull_request
30-
}
24+
url: githubData.html_url
25+
};
3126
};
3227

3328
module.exports = getActionData;

Diff for: src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ const generateMutationQuery = require('./generate-mutation-query');
1313
const action = core.getInput('action') || 'update';
1414

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

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

2121
// Get the column ID from searching for the project and card Id if it exists
22-
const projectQuery = generateProjectQuery(url, is_pr, project);
22+
const projectQuery = generateProjectQuery(url, github.context.payload, project);
2323

2424
core.debug(projectQuery);
2525

0 commit comments

Comments
 (0)