github_ci_tools 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ac43386e1eeba1bbb03ff53516925f6f23165538c06d195bf4829db0c21adcb4
4
+ data.tar.gz: cf5bbcff414684a967477970404e84c5bf5eadbeed91308401193092a4f37209
5
+ SHA512:
6
+ metadata.gz: 28aa6d73b3a80bcac3d2f2d6b92d4479c0bb7fe33cdeae6c45a08e46d883cdf8837ee5df54638b2edab95aec6ab049b6a8444a810c656ed3801aae7e9defebac
7
+ data.tar.gz: d0cd49e1ad1345c2890801c2c52523bf2722477ca4c32e946d34c6f6c698e1f6527f5a611eb33678aac25c517afa795f64f58f8fd3226b34e1640f1bd9cc676a
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/README.md ADDED
@@ -0,0 +1 @@
1
+ place holder readme
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'github_ci_tools'
4
+
5
+ puts GitHubApp.new(client_id: ENV['CLIENT_ID']).token
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'openssl'
4
+ require 'jwt'
5
+ require 'faraday'
6
+ require 'json'
7
+
8
+ # Represents a GitHub App that has permissions for specific repos.
9
+ # For the permission details to perform required actions on the GitHub
10
+ # API see the GitHub documentation.
11
+ class GitHubApp
12
+ def initialize(client_id:)
13
+ @client_id = client_id
14
+ end
15
+
16
+ def token
17
+ conn = Faraday.new(
18
+ url: 'https://api.github.com',
19
+ headers: {
20
+ 'Authorization' => "Bearer #{jwt}",
21
+ 'Accept' => 'application/vnd.github.v3+json'
22
+ }
23
+ )
24
+
25
+ response = conn.post("app/installations/#{ENV.fetch('GITHUB_INSTALLATION_ID', '')}/access_tokens")
26
+
27
+ if response.success?
28
+ response_body = JSON.parse(response.body)
29
+ response_body['token']
30
+ else
31
+ puts "API call failed! Response status: #{response.status}"
32
+ puts "Response body: #{response.body}"
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ attr_reader :client_id
39
+
40
+ def jwt
41
+ decoded_key = Base64.decode64(ENV.fetch('GITHUB_PRIVATE_KEY_B64', ''))
42
+ private_key = OpenSSL::PKey::RSA.new(decoded_key)
43
+
44
+ payload = {
45
+ iat: Time.now.to_i,
46
+ exp: Time.now.to_i + (9 * 60),
47
+ iss: client_id
48
+ }
49
+
50
+ JWT.encode(payload, private_key, 'RS256')
51
+ end
52
+ end
@@ -0,0 +1,12 @@
1
+ # Represents a GitHub Event that can be dispatched to a specific repository.
2
+ # These events can trigger additional workflows in a pipeline.
3
+ class GitHubEvent
4
+ def initialize(event_type:, payload:)
5
+ @event_type = event_type
6
+ @payload = payload
7
+ end
8
+
9
+ def dispatch
10
+
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "github_ci_tools/github_app"
4
+
5
+ module GitHubCITools
6
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github_ci_tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Liz Johnson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-09-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jwt
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.8'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: openssl
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.12'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.12'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.18'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.18'
97
+ description:
98
+ email: lizdrennan8@gmail.com
99
+ executables:
100
+ - generate_token
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - Gemfile
105
+ - README.md
106
+ - bin/generate_token
107
+ - lib/github_ci_tools.rb
108
+ - lib/github_ci_tools/github_app.rb
109
+ - lib/github_ci_tools/github_event.rb
110
+ homepage: https://github.com/lizzypy/github-ci-tools
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '3.0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubygems_version: 3.3.7
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Authenticate to the GitHub API using a GitHub App
133
+ test_files: []