Skip to content

Commit

Permalink
Update labels (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
guibranco authored Feb 18, 2024
1 parent 70ab4af commit 1b39e03
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Src/pullRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function handlePullRequest($pullRequest)
"assigneesUrl" => "repos/" . $pullRequest->RepositoryOwner . "/" . $pullRequest->RepositoryName . "/issues/" . $pullRequest->Number . "/assignees",
"collaboratorsUrl" => "repos/" . $pullRequest->RepositoryOwner . "/" . $pullRequest->RepositoryName . "/collaborators",
"requestReviewUrl" => "repos/" . $pullRequest->RepositoryOwner . "/" . $pullRequest->RepositoryName . "/issues/" . $pullRequest->Number . "/requested_reviewers",
"issuesUrl" => "repos/" . $pullRequest->RepositoryOwner . "/" . $pullRequest->RepositoryName . "/issues",
"prLabelsUrl" => "repos/" . $pullRequest->RepositoryOwner . "/" . $pullRequest->RepositoryName . "/issues/" . $pullRequest->Number . "/labels"
);

$pullRequestResponse = requestGitHub($metadata["token"], $metadata["pullRequestUrl"]);
Expand Down Expand Up @@ -81,8 +83,19 @@ function handlePullRequest($pullRequest)
}"
);

$referencedIssue = requestGitHub($metadata["token"], "graphql", $referencedIssueQuery);
print_r($referencedIssue["body"]);
$referencedIssueResponse = requestGitHub($metadata["token"], "graphql", $referencedIssueQuery);
$referencedIssue = json_decode($referencedIssueResponse["body"]);
if (count($referencedIssue->data->repository->pullRequest->closingIssuesReferences->nodes) > 0) {
$issueNumber = $referencedIssue->data->repository->pullRequest->closingIssuesReferences->nodes[0]->number;
$issueResponse = requestGitHub($metadata["token"], $metadata["issuesUrl"] . "/" . $issueNumber);

$labels = array_column(json_decode($issueResponse["body"])->labels, "name");
$body = array("labels" => array("WIP"));
requestGitHub($metadata["token"], $metadata["issuesUrl"] . "/" . $issueNumber . "/labels", $labels);
$body = array("labels" => $labels);
requestGitHub($metadata["token"], $metadata["prLabelsUrl"] . "/labels", $labels);
}


if (!$botReviewed) {
$body = array("event" => "APPROVE");
Expand Down

0 comments on commit 1b39e03

Please sign in to comment.