Skip to content

Commit

Permalink
refactor args
Browse files Browse the repository at this point in the history
  • Loading branch information
allisonport-db committed Dec 3, 2021
1 parent 2af3cf0 commit 7642fd5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion 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} is_pr - Whether the event is a Pull Request (false if it's an Issue)
* @param {string} payload - The event payload
* @param {string} project - The project to find
*/
const projectQuery = (url, is_pr, project) =>
const projectQuery = (url, payload, project) =>
`query {
resource( url: "${url}" ) {
... on ${!is_pr ? 'Issue' : 'PullRequest'} {
... on ${!payload.pull_request && !payload.issue.pull_request ? 'Issue' : 'PullRequest'} {
projectCards {
nodes {
id
Expand Down
3 changes: 1 addition & 2 deletions src/get-action-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ const getActionData = githubContext => {
eventName,
action: payload.action,
nodeId: githubData.node_id,
url: githubData.html_url,
is_pr: !!payload.pull_request || !!payload.issue.pull_request
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, is_pr} = getActionData(github.context);
const {eventName, 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, is_pr, project);
const projectQuery = generateProjectQuery(url, github.context.payload, project);

core.debug(projectQuery);

Expand Down

0 comments on commit 7642fd5

Please sign in to comment.