Class: Jekyll::Gitlab::Letsencrypt::Commiter
- Inherits:
-
Object
- Object
- Jekyll::Gitlab::Letsencrypt::Commiter
- Defined in:
- lib/jekyll/gitlab/letsencrypt/committer.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
Instance Method Summary collapse
- #commit! ⇒ Object
- #commit_file! ⇒ Object
- #create_branch! ⇒ Object
-
#initialize(content) ⇒ Commiter
constructor
A new instance of Commiter.
Constructor Details
#initialize(content) ⇒ Commiter
Returns a new instance of Commiter.
12 13 14 |
# File 'lib/jekyll/gitlab/letsencrypt/committer.rb', line 12 def initialize(content) @content = content end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
8 9 10 |
# File 'lib/jekyll/gitlab/letsencrypt/committer.rb', line 8 def content @content end |
Instance Method Details
#commit! ⇒ Object
16 17 18 19 |
# File 'lib/jekyll/gitlab/letsencrypt/committer.rb', line 16 def commit! create_branch! unless branch_exists? commit_file! end |
#commit_file! ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jekyll/gitlab/letsencrypt/committer.rb', line 32 def commit_file! Jekyll.logger.info "Commiting challenge file as #{filename}" connection.run_request(request_method, nil, nil, nil) do |req| req.url "projects/#{repo_id}/repository/files" req.body = { file_path: filename, commit_message: "Automated Let's Encrypt renewal", branch_name: branch, content: content }.to_json end Jekyll.logger.info "Done Commiting! Check https://gitlab.com/#{gitlab_repo}/commits/#{branch}" end |
#create_branch! ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jekyll/gitlab/letsencrypt/committer.rb', line 21 def create_branch! Jekyll.logger.info "Creating branch #{branch}.." connection.post do |req| req.url "projects/#{repo_id}/repository/branches" req.body = { branch_name: branch, ref: 'master' }.to_json end end |