Add GitHub token creation instructions

Make rubocop happier too.

[skip ci]
pull/10917/head
Christophe Bliard 2 years ago
parent 824bde8f51
commit 6dd7af968a
No known key found for this signature in database
GPG Key ID: 2BC07603210C3FA4
  1. 19
      script/github_pr_errors

@ -10,8 +10,11 @@ require 'tempfile'
# current branch # current branch
branch_name = `git rev-parse --abbrev-ref HEAD`.strip branch_name = `git rev-parse --abbrev-ref HEAD`.strip
raise "Missing GITHUB_USERNAME env" unless ENV['GITHUB_USERNAME'] if !ENV['GITHUB_USERNAME']
raise "Missing GITHUB_TOKEN env" unless ENV['GITHUB_TOKEN'] raise "Missing GITHUB_USERNAME env"
elsif !ENV['GITHUB_TOKEN']
raise "Missing GITHUB_TOKEN env, go to https://github.com/settings/tokens and create one with 'repo' access"
end
def get_http(path, json: true) def get_http(path, json: true)
url = url =
@ -23,9 +26,9 @@ def get_http(path, json: true)
response = RestClient::Request.new( response = RestClient::Request.new(
method: :get, method: :get,
url: url, url:,
user: ENV['GITHUB_USERNAME'], user: ENV.fetch('GITHUB_USERNAME'),
password: ENV['GITHUB_TOKEN'] password: ENV.fetch('GITHUB_TOKEN')
).execute ).execute
if json if json
@ -33,7 +36,7 @@ def get_http(path, json: true)
else else
response.to_str response.to_str
end end
rescue => e rescue StandardError => e
warn "Failed to perform API request #{url}: #{e} #{e.message}" warn "Failed to perform API request #{url}: #{e} #{e.message}"
end end
@ -42,12 +45,12 @@ warn "Looking for the last action in branch #{branch_name}"
response = get_http "actions/runs?branch=#{CGI.escape(branch_name)}" response = get_http "actions/runs?branch=#{CGI.escape(branch_name)}"
last_test_action = last_test_action =
response response['workflow_runs']
.dig('workflow_runs')
.select { |entry| entry['name'] == 'Test suite' } .select { |entry| entry['name'] == 'Test suite' }
.max_by { |entry| entry['run_number'] } .max_by { |entry| entry['run_number'] }
raise "No action run found for branch #{branch_name}" unless last_test_action raise "No action run found for branch #{branch_name}" unless last_test_action
log_response = get_http last_test_action['logs_url'], json: false log_response = get_http last_test_action['logs_url'], json: false
errors = [] errors = []

Loading…
Cancel
Save