diff --git a/.github/DISCUSSION_TEMPLATE/enterprise.yml b/.github/DISCUSSION_TEMPLATE/enterprise.yml index e3626c900..bed32cb36 100644 --- a/.github/DISCUSSION_TEMPLATE/enterprise.yml +++ b/.github/DISCUSSION_TEMPLATE/enterprise.yml @@ -11,7 +11,8 @@ body: - type: dropdown attributes: label: Select Topic Area - description: What would you like to discuss? + name: "Topic" + description: "What would you like to discuss?" options: - Question - Product Feedback diff --git a/.github/actions/comment b/.github/actions/comment index 050ac0554..3606df276 100755 --- a/.github/actions/comment +++ b/.github/actions/comment @@ -6,7 +6,6 @@ require_relative "../lib/github" stale_label_id = "LA_kwDOEfmk4M8AAAABYVCU-g" owner = "community" repo = "community" -only_these_categories = ["Copilot"] body =< 0 && Date.parse(r.dig("comments", "nodes", 0, "createdAt")).after?(cutoff_date) } - #.reject { |r| r.dig("labels", "nodes").map { |l| l["name"] }.include?("stale") } - .select { |r| r.dig("labels", "nodes").map { |l| l["name"] }.include?("stale") } .map do |c| + labelled = c.dig("labels", "nodes").map { |l| l["name"] }.include?("inactive") Discussion.new( c["id"], c["url"], - c["title"] + c["title"], + labelled ) end end diff --git a/.github/lib/github.rb b/.github/lib/github.rb index cf426f56d..6428abf75 100644 --- a/.github/lib/github.rb +++ b/.github/lib/github.rb @@ -14,7 +14,9 @@ def initialize headers: { Authorization: "bearer #{ENV['GITHUB_TOKEN']}" } - ) + ) do |f| + f.response :raise_error + end end def post(graphql:) @@ -25,19 +27,21 @@ def post(graphql:) query = end_cursor.nil? ? graphql.sub(/after.*\n/, "") : graphql.sub("%ENDCURSOR%", end_cursor) response = @conn.post("/graphql") do |req| + req.options.timeout = 10 req.body = { query: }.to_json end - unless response.status == 200 - puts "#{response.reason_phrase}: #{JSON.parse(response.body).dig("message")}" - exit + + if rate_limit = JSON.parse(response.body).dig("data", "rateLimit") + puts "Rate limit: limit - #{rate_limit["limit"]}, cost - #{rate_limit["cost"]}, remaining - #{rate_limit["remaining"]}, resetAt - #{rate_limit["resetAt"]}" end node = JSON.parse(response.body).dig("data", "repository") + node = JSON.parse(response.body).dig("data", "search") if node.nil? nodes << node - break unless node.dig("discussions", "pageInfo", "hasNextPage") + break unless node&.dig("pageInfo", "hasNextPage") - end_cursor = node.dig("discussions", "pageInfo", "endCursor") + end_cursor = node.dig("pageInfo", "endCursor") end nodes.flatten diff --git a/.github/workflows/comment-on-dormant-discussions.yml b/.github/workflows/comment-on-dormant-discussions.yml index c68036245..74d79e993 100644 --- a/.github/workflows/comment-on-dormant-discussions.yml +++ b/.github/workflows/comment-on-dormant-discussions.yml @@ -1,6 +1,10 @@ name: Comment on dormant discussions -on: workflow_dispatch +on: + workflow_dispatch: + schedule: + # At minute 23 past every 2nd hour + - cron: '23 */2 * * *' jobs: build: