Skip to content

Commit

Permalink
Board automation: Refresh GitHub IDs, use label ID instead of name
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Jul 11, 2024
1 parent b983d37 commit 9ac24af
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 21 deletions.
46 changes: 29 additions & 17 deletions packages/meta/src/project_board_automation/GitHubApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ static public function extractProjectItemHasLabelByName($projectItem, $labelName
}

static public function extractProjectItemFieldValueByName($projectItem, $fieldName) {
var_dump($projectItem);
foreach($projectItem['fieldValues']['nodes'] as $fieldValue) {
if(isset($fieldValue['field']['name']) && $fieldValue['field']['name'] === $fieldName) {
return $fieldValue;
Expand Down Expand Up @@ -368,33 +369,44 @@ public function getOrCreateLabel($repoId, $labelName)
public function getLabelIdByName($repoId, $labelName)
{
$query = <<<'GRAPHQL'
query($repoId: ID!) {
node(id: $repoId) {
... on Repository {
labels(first: 100) {
nodes {
id
name
query($repoId: ID!, $cursor: String) {
node(id: $repoId) {
... on Repository {
labels(first: 100, after: $cursor) {
nodes {
id
name
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
}
}
GRAPHQL;

$variables = [
'repoId' => $repoId,
'labelName' => $labelName,
'repoId' => $repoId,
];

$response = $this->graphqlQuery( $query, $variables );
$labels = $response['data']['node']['labels']['nodes'];
foreach ($labels as $label) {
if ($label['name'] === $labelName) {
return $label['id'];
$labelId = null;
do {
$response = $this->graphqlQuery($query, $variables);
$labels = $response['data']['node']['labels']['nodes'];
foreach ($labels as $label) {
if ($label['name'] === $labelName) {
$labelId = $label['id'];
break 2; // Exit both the foreach and do-while loop
}
}
}
$hasNextPage = $response['data']['node']['labels']['pageInfo']['hasNextPage'];
$variables['cursor'] = $response['data']['node']['labels']['pageInfo']['endCursor'];
var_dump($variables);
} while ($hasNextPage);

return null;
return $labelId;
}

public function commentOnIssue( $issueId, $comment ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function moveBackToInboxAfterAuthorsReply($projectItem)
$this->projectId,
$projectItem['id'],
$this->statusFieldId,
'Inbox'
$this->githubIds['fields']['status']['options']['inbox']
);
return true;
}
Expand Down
39 changes: 36 additions & 3 deletions packages/meta/src/project_board_automation/github_ids.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,23 @@
'id' => 'PVTSSF_lADOAAQ2Js4AdkmezgTL8Wc',
'options' =>
array (
'future_work' => '5d770dea',
'needs_triage' => '0b055ebb',
'inbox' => '4aca50ce',
'needs_triage_our_reply' => '0b055ebb',
'needs_authors_reply' => '20567755',
'up_next' => '08afe404',
'future_work' => '5d770dea',
'in_progress' => '47fc9ee4',
'needs_review' => '4cc61d42',
'reviewed' => '0f27f789',
'blocked' => '1effdd50',
'done' => '98236657',
'not_doing' => '2a2852fd',
'needs_authors_reply' => '20567755',
'project_triage' => '3171d170',
'on_the_roadmap' => '0480ee83',
'project_not_now' => 'e0a06684',
'project_up_soon' => '3ea1bfc9',
'project_in_progress' => '63a919bb',
'project_shipped' => 'aff92a27',
),
),
'priority' =>
Expand All @@ -39,5 +47,30 @@
'triage' => 'cc5f4099',
),
),
'project' =>
array (
'id' => 'PVTSSF_lADOAAQ2Js4Adkmezgccvic',
'options' =>
array (
'offline_support' => '90ba7274',
'zero_crashes' => '30dc7c82',
'wordpress_for_docs' => 'dcfe047b',
'routing' => '76b57c16',
'playground_on_learn_wordpress_org' => '010e980f',
'boot_protocol' => 'f7ff8a02',
'other_task' => 'db7cd0df',
'documentation_v2' => 'c2eb9f26',
'php_blueprints' => '5a5cbf79',
),
),
'awaiting_authors_reply_' =>
array (
'id' => 'PVTSSF_lADOAAQ2Js4AdkmezgcySxY',
'options' =>
array (
'yes' => '6f2db843',
'no' => '9f7e5343',
),
),
),
);

0 comments on commit 9ac24af

Please sign in to comment.