Class: Jets::Git::Github
Instance Method Summary collapse
- #build_type ⇒ Object
- #git_branch ⇒ Object
- #git_sha ⇒ Object
- #git_url ⇒ Object
- #info ⇒ Object
-
#pr ⇒ Object
GitHub webhook JSON payload in file and path is set in GITHUB_EVENT_PATH.
Methods inherited from Base
Instance Method Details
#build_type ⇒ Object
44 45 46 |
# File 'lib/jets/git/github.rb', line 44 def build_type ENV["GITHUB_EVENT_NAME"] end |
#git_branch ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/jets/git/github.rb', line 16 def git_branch if build_type == "pull_request" pr.dig("pull_request", "head", "ref") else # push ENV["GITHUB_REF_NAME"] end end |
#git_sha ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/jets/git/github.rb', line 24 def git_sha if build_type == "pull_request" pr.dig("pull_request", "head", "sha") else # push ENV["GITHUB_SHA"] end end |
#git_url ⇒ Object
32 33 34 35 36 |
# File 'lib/jets/git/github.rb', line 32 def git_url host = ENV["GITHUB_SERVER_URL"] || "https://github.com" full_repo = ENV["GITHUB_REPOSITORY"] "#{host}/#{full_repo}" end |
#info ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/jets/git/github.rb', line 3 def info info = { git_system: "github", git_branch: git_branch, git_sha: git_sha, git_dirty: false # git_message: nil, # git_version: nil, } info[:git_url] = git_url if git_url info end |
#pr ⇒ Object
GitHub webhook JSON payload in file and path is set in GITHUB_EVENT_PATH
39 40 41 42 |
# File 'lib/jets/git/github.rb', line 39 def pr return {} unless ENV["GITHUB_EVENT_PATH"] JSON.load(IO.read(ENV["GITHUB_EVENT_PATH"])) end |