class GitHub
docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
Attributes
api_url[R]
repository[R]
server_url[R]
token[R]
workspace[R]
Public Class Methods
name_with_owner_from(url)
click to toggle source
# File lib/github.rb, line 26 def name_with_owner_from(url) regex = %r{(?<x>(?<scheme>https|ssh)://)?(?<username>git@)?github.com[:|/](?<nwo>\w+/\w+)(?<extension>\.git)?} match = url.match(regex) match && match["nwo"] end
new( api_url: default_api_url, repository: ENV["GITHUB_REPOSITORY"], server_url: ENV.fetch("GITHUB_SERVER_URL", "https://github.com"), token: default_token, workspace: ENV.fetch("GITHUB_WORKSPACE", Dir.pwd) )
click to toggle source
# File lib/github.rb, line 7 def initialize( api_url: default_api_url, repository: ENV["GITHUB_REPOSITORY"], server_url: ENV.fetch("GITHUB_SERVER_URL", "https://github.com"), token: default_token, workspace: ENV.fetch("GITHUB_WORKSPACE", Dir.pwd) ) @api_url = api_url @repository = repository @server_url = server_url @token = token @workspace = workspace end
Public Instance Methods
create(action)
click to toggle source
# File lib/github.rb, line 21 def create(action) action.run_against(Dependabot.octokit) end
Private Instance Methods
default_api_url()
click to toggle source
# File lib/github.rb, line 35 def default_api_url ENV.fetch("GITHUB_API_URL", "https://api.github.com") end
default_token()
click to toggle source
# File lib/github.rb, line 39 def default_token ENV.fetch("GITHUB_TOKEN") do |_name| file = Pathname.new(Dir.home).join(".config/gh/hosts.yml") if file.exist? YAML .safe_load(file.read) &.fetch("github.com") &.fetch("oauth_token") end end end