|
1 | 1 | 'use strict'
|
2 | 2 | const core = require('@actions/core')
|
3 | 3 | const { getOctokit, context } = require('@actions/github')
|
| 4 | +const { graphql } = require('@octokit/graphql') |
4 | 5 | const list = require('safe-parse-list')
|
5 | 6 | const ejs = require('ejs')
|
6 | 7 | const meetings = require('./lib/meetings')
|
@@ -97,6 +98,71 @@ const pkg = require('./package.json')
|
97 | 98 | }
|
98 | 99 |
|
99 | 100 | const agendaIssues = await agenda.fetchAgendaItems(client, repos, agendaLabel)
|
| 101 | + |
| 102 | + for (const r of repos) { |
| 103 | + let hasNextPage = true |
| 104 | + let endCursor = null |
| 105 | + do { |
| 106 | + const query = ` |
| 107 | + query($owner: String!, $name: String!, $after: String) { |
| 108 | + repository(owner: $owner, name: $name) { |
| 109 | + discussions(first: 100, after: $after) { |
| 110 | + pageInfo { |
| 111 | + endCursor |
| 112 | + hasNextPage |
| 113 | + } |
| 114 | + edges { |
| 115 | + cursor |
| 116 | + node { |
| 117 | + id |
| 118 | + title |
| 119 | + url |
| 120 | + labels(first: 10) { |
| 121 | + nodes { |
| 122 | + color |
| 123 | + name |
| 124 | + } |
| 125 | + } |
| 126 | + } |
| 127 | + } |
| 128 | + } |
| 129 | + } |
| 130 | + } |
| 131 | + ` |
| 132 | + const variables = { |
| 133 | + owner: r.owner, |
| 134 | + name: r.repo, |
| 135 | + after: endCursor |
| 136 | + } |
| 137 | + const _agendaDiscussions = await graphql(query, { |
| 138 | + ...variables, |
| 139 | + headers: { |
| 140 | + authorization: `token ${token}` |
| 141 | + } |
| 142 | + }) |
| 143 | + const discussions = _agendaDiscussions?.repository?.discussions |
| 144 | + if (discussions) { |
| 145 | + const { edges, pageInfo } = discussions |
| 146 | + for (const edge of edges) { |
| 147 | + const labels = edge.node?.labels.nodes |
| 148 | + if (Array.isArray(labels) && labels.some(label => label.name === agendaLabel)) { |
| 149 | + console.log(`Adding Discussion: ${edge.node.url}`) |
| 150 | + agendaIssues.push({ |
| 151 | + id: edge.node.id, |
| 152 | + html_url: edge.node.url, |
| 153 | + title: edge.node.title |
| 154 | + }) |
| 155 | + } |
| 156 | + } |
| 157 | + hasNextPage = pageInfo.hasNextPage |
| 158 | + endCursor = pageInfo.endCursor |
| 159 | + } else { |
| 160 | + hasNextPage = false |
| 161 | + } |
| 162 | + } while (hasNextPage) |
| 163 | + } |
| 164 | + |
| 165 | + console.log(`Found ${agendaIssues.length} total issues for agenda`) |
100 | 166 |
|
101 | 167 | const opts = {
|
102 | 168 | ...repo,
|
|
0 commit comments