ruboty-circle_ci_v2 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.rakeTasks +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +47 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/ruboty/circle_ci_v2.rb +15 -0
- data/lib/ruboty/circle_ci_v2/actions/base.rb +62 -0
- data/lib/ruboty/circle_ci_v2/actions/remember.rb +26 -0
- data/lib/ruboty/circle_ci_v2/actions/run_pipeline.rb +34 -0
- data/lib/ruboty/circle_ci_v2/version.rb +5 -0
- data/lib/ruboty/handlers/circle_ci_v2.rb +25 -0
- data/ruboty-circle_ci_v2.gemspec +36 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bb5c88f486abf15fb1f99e595f27c1a977b613f3ca2a4f20c9159baa72a2003f
|
4
|
+
data.tar.gz: 19d47b2d3fe28396de69376aecb3c4277428ba971da1ba73b86d6ff0c252b3f5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0b6630f26a998de44aad92fca91f89406040f019a61a392de282949db8649b12e49f3abfe294708ccba29647cfe41f30e5a87ad62fdad50e70f0c1ad744f015d
|
7
|
+
data.tar.gz: 2824f3a06bdd11d06dc2a44f2767ca185d4f3f4d4952b18a466017721dc91674484c45d39de90958e106812f45141a953216f9791cc5ceb4e3788ebd27485e56
|
data/.gitignore
ADDED
data/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ruboty-circle_ci_v2 (0.1.0)
|
5
|
+
faraday
|
6
|
+
ruboty
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (6.0.3.2)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 0.7, < 2)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
17
|
+
concurrent-ruby (1.1.6)
|
18
|
+
dotenv (2.7.5)
|
19
|
+
faraday (1.0.1)
|
20
|
+
multipart-post (>= 1.2, < 3)
|
21
|
+
i18n (1.8.3)
|
22
|
+
concurrent-ruby (~> 1.0)
|
23
|
+
mem (0.1.5)
|
24
|
+
minitest (5.14.1)
|
25
|
+
multipart-post (2.1.1)
|
26
|
+
rake (13.0.1)
|
27
|
+
ruboty (1.3.0)
|
28
|
+
activesupport
|
29
|
+
bundler
|
30
|
+
dotenv
|
31
|
+
mem
|
32
|
+
slop
|
33
|
+
slop (4.8.1)
|
34
|
+
thread_safe (0.3.6)
|
35
|
+
tzinfo (1.2.7)
|
36
|
+
thread_safe (~> 0.1)
|
37
|
+
zeitwerk (2.3.1)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
ruby
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
rake (>= 12.3.3)
|
44
|
+
ruboty-circle_ci_v2!
|
45
|
+
|
46
|
+
BUNDLED WITH
|
47
|
+
1.17.2
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Ruboty::CircleCiV2
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ruboty/circle_ci_v2`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ruboty-circle_ci_v2'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ruboty-circle_ci_v2
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruboty-circle_ci_v2.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ruboty/circle_ci_v2"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "json"
|
3
|
+
require "ruboty"
|
4
|
+
require "ruboty/circle_ci_v2/actions/base"
|
5
|
+
require "ruboty/circle_ci_v2/actions/remember"
|
6
|
+
require "ruboty/circle_ci_v2/actions/run_pipeline"
|
7
|
+
require "ruboty/circle_ci_v2/version"
|
8
|
+
require "ruboty/handlers/circle_ci_v2"
|
9
|
+
|
10
|
+
module Ruboty
|
11
|
+
module CircleCIV2
|
12
|
+
class Error < StandardError; end
|
13
|
+
# Your code goes here...
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module CircleCIV2
|
3
|
+
module Actions
|
4
|
+
class Base
|
5
|
+
NAMESPACE = "circle_ci_v2"
|
6
|
+
|
7
|
+
attr_reader :message
|
8
|
+
|
9
|
+
def initialize(message)
|
10
|
+
@message = message
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def personal_api_tokens
|
16
|
+
message.robot.brain.data[NAMESPACE] ||= {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def body
|
20
|
+
message[:description] || ""
|
21
|
+
end
|
22
|
+
|
23
|
+
def sender_name
|
24
|
+
message.from_name
|
25
|
+
end
|
26
|
+
|
27
|
+
def require_personal_api_token
|
28
|
+
message.reply("I don't know your CircleCI Personal API Token")
|
29
|
+
end
|
30
|
+
|
31
|
+
def has_personal_api_token?
|
32
|
+
!!personal_api_token
|
33
|
+
end
|
34
|
+
|
35
|
+
def personal_api_token
|
36
|
+
@personal_api_token ||= personal_api_tokens[sender_name]
|
37
|
+
end
|
38
|
+
|
39
|
+
def connection
|
40
|
+
Faraday.new(url: api_endpoint) do |builder|
|
41
|
+
builder.request :url_encoded
|
42
|
+
builder.adapter :net_http
|
43
|
+
builder.basic_auth personal_api_token, ""
|
44
|
+
builder.headers["Content-Type"] = "application/json"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def repository
|
49
|
+
message[:repo]
|
50
|
+
end
|
51
|
+
|
52
|
+
def api_endpoint
|
53
|
+
"#{circle_ci_v2_base_url}/#{repository}/pipeline"
|
54
|
+
end
|
55
|
+
|
56
|
+
def circle_ci_v2_base_url
|
57
|
+
"https://circleci.com/api/v2/project"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module CircleCIV2
|
3
|
+
module Actions
|
4
|
+
class Remember < Base
|
5
|
+
def call
|
6
|
+
remember
|
7
|
+
report
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def report
|
13
|
+
message.reply("Remembered #{sender_name}'s CircleCI personal access token")
|
14
|
+
end
|
15
|
+
|
16
|
+
def remember
|
17
|
+
personal_api_tokens[sender_name] = given_personal_api_token
|
18
|
+
end
|
19
|
+
|
20
|
+
def given_personal_api_token
|
21
|
+
message[:token]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module CircleCIV2
|
3
|
+
module Actions
|
4
|
+
class RunPipeline < Base
|
5
|
+
def call
|
6
|
+
if has_personal_api_token?
|
7
|
+
run_pipeline
|
8
|
+
else
|
9
|
+
require_personal_api_token
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def run_pipeline
|
16
|
+
connection.post do |request|
|
17
|
+
request.body = {
|
18
|
+
branch: branch,
|
19
|
+
parameters: parameters
|
20
|
+
}.to_json
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def branch
|
25
|
+
message[:branch]
|
26
|
+
end
|
27
|
+
|
28
|
+
def parameters
|
29
|
+
JSON.parse(message[:params])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Handlers
|
3
|
+
class CircleCIV2 < Base
|
4
|
+
on(
|
5
|
+
/remember my ciecleci personal api token (?<token>.+)\z/,
|
6
|
+
name: "remember",
|
7
|
+
description: "Remember sender's CircleCI personal api token",
|
8
|
+
)
|
9
|
+
|
10
|
+
on(
|
11
|
+
/run circleci pipeline of branch (?<branch>.+) on (?<repo>.+) with params (?<params>.+)\z/,
|
12
|
+
name: "run_pipeline",
|
13
|
+
description: "Run pipeline with params",
|
14
|
+
)
|
15
|
+
|
16
|
+
def remember(message)
|
17
|
+
Ruboty::CircleCIV2::Actions::Remember.new(message).call
|
18
|
+
end
|
19
|
+
|
20
|
+
def run_pipeline(message)
|
21
|
+
Ruboty::CircleCIV2::Actions::RunPipeline.new(message).call
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative 'lib/ruboty/circle_ci_v2/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "ruboty-circle_ci_v2"
|
5
|
+
spec.version = Ruboty::CircleCIV2::VERSION
|
6
|
+
spec.authors = ["Kouhei Suzuki"]
|
7
|
+
spec.email = ["kouhei.szk@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = "Ruboty plugin for CircleCI"
|
10
|
+
spec.description = "Ruboty plugin for CircleCI"
|
11
|
+
spec.homepage = "https://github.com/refcome/ruboty-circle_ci_v2"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
+
|
14
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
15
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
16
|
+
if spec.respond_to?(:metadata)
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
spec.metadata["changelog_uri"] = spec.homepage
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
"public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
28
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
spec.add_dependency "ruboty"
|
35
|
+
spec.add_dependency "faraday"
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-circle_ci_v2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kouhei Suzuki
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruboty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Ruboty plugin for CircleCI
|
42
|
+
email:
|
43
|
+
- kouhei.szk@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rakeTasks"
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- lib/ruboty/circle_ci_v2.rb
|
57
|
+
- lib/ruboty/circle_ci_v2/actions/base.rb
|
58
|
+
- lib/ruboty/circle_ci_v2/actions/remember.rb
|
59
|
+
- lib/ruboty/circle_ci_v2/actions/run_pipeline.rb
|
60
|
+
- lib/ruboty/circle_ci_v2/version.rb
|
61
|
+
- lib/ruboty/handlers/circle_ci_v2.rb
|
62
|
+
- ruboty-circle_ci_v2.gemspec
|
63
|
+
homepage: https://github.com/refcome/ruboty-circle_ci_v2
|
64
|
+
licenses: []
|
65
|
+
metadata:
|
66
|
+
homepage_uri: https://github.com/refcome/ruboty-circle_ci_v2
|
67
|
+
source_code_uri: https://github.com/refcome/ruboty-circle_ci_v2
|
68
|
+
changelog_uri: https://github.com/refcome/ruboty-circle_ci_v2
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.3.0
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubygems_version: 3.0.3
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Ruboty plugin for CircleCI
|
88
|
+
test_files: []
|