tayo 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/.DS_Store +0 -0
- data/README.md +100 -0
- data/Rakefile +4 -0
- data/exe/tayo +5 -0
- data/lib/tayo/cli.rb +31 -0
- data/lib/tayo/commands/cf.rb +390 -0
- data/lib/tayo/commands/gh.rb +389 -0
- data/lib/tayo/commands/init.rb +374 -0
- data/lib/tayo/version.rb +5 -0
- data/lib/tayo.rb +8 -0
- data/pkg/homebody-0.1.0.gem +0 -0
- data/sig/tayo.rbs +4 -0
- metadata +112 -0
@@ -0,0 +1,389 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "colorize"
|
4
|
+
require "json"
|
5
|
+
require "git"
|
6
|
+
require "yaml"
|
7
|
+
require "tty-prompt"
|
8
|
+
|
9
|
+
module Tayo
|
10
|
+
module Commands
|
11
|
+
class Gh
|
12
|
+
def execute
|
13
|
+
puts "๐ GitHub ์ ์ฅ์ ๋ฐ ์ปจํ
์ด๋ ๋ ์ง์คํธ๋ฆฌ ์ค์ ์ ์์ํฉ๋๋ค...".colorize(:green)
|
14
|
+
|
15
|
+
unless rails_project?
|
16
|
+
puts "โ Rails ํ๋ก์ ํธ๊ฐ ์๋๋๋ค. Rails ํ๋ก์ ํธ ๋ฃจํธ์์ ์คํํด์ฃผ์ธ์.".colorize(:red)
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
puts "\n[1/7] GitHub CLI ์ค์น ํ์ธ".colorize(:blue)
|
21
|
+
check_github_cli
|
22
|
+
|
23
|
+
puts "\n[2/7] GitHub ๋ก๊ทธ์ธ ํ์ธ".colorize(:blue)
|
24
|
+
check_github_auth
|
25
|
+
|
26
|
+
puts "\n[3/7] ์ปจํ
์ด๋ ๋ ์ง์คํธ๋ฆฌ ๊ถํ ํ์ธ".colorize(:blue)
|
27
|
+
check_container_registry_permission
|
28
|
+
|
29
|
+
puts "\n[4/7] Git ์ ์ฅ์ ์ด๊ธฐํ".colorize(:blue)
|
30
|
+
init_git_repo
|
31
|
+
|
32
|
+
puts "\n[5/7] GitHub ์ ์ฅ์ ์์ฑ".colorize(:blue)
|
33
|
+
create_github_repository
|
34
|
+
|
35
|
+
puts "\n[6/7] ์ปจํ
์ด๋ ๋ ์ง์คํธ๋ฆฌ ์ค์ ".colorize(:blue)
|
36
|
+
create_container_registry
|
37
|
+
|
38
|
+
puts "\n[7/7] ๋ฐฐํฌ ์ค์ ํ์ผ ์์ฑ".colorize(:blue)
|
39
|
+
create_deploy_config
|
40
|
+
|
41
|
+
puts "\n๐ ๋ชจ๋ ์ค์ ์ด ์๋ฃ๋์์ต๋๋ค!".colorize(:green)
|
42
|
+
puts "\n๋ค์ ์ ๋ณด๊ฐ ์ค์ ๋์์ต๋๋ค:".colorize(:yellow)
|
43
|
+
puts "โข GitHub ์ ์ฅ์: https://github.com/#{@username}/#{@repo_name}".colorize(:cyan)
|
44
|
+
puts "โข Container Registry: #{@registry_url}".colorize(:cyan)
|
45
|
+
puts "โข ๋ฐฐํฌ ์ค์ : config/deploy.yml".colorize(:cyan)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def rails_project?
|
51
|
+
File.exist?("Gemfile") && File.exist?("config/application.rb")
|
52
|
+
end
|
53
|
+
|
54
|
+
def check_github_cli
|
55
|
+
if system("gh --version", out: File::NULL, err: File::NULL)
|
56
|
+
puts "โ
GitHub CLI๊ฐ ์ด๋ฏธ ์ค์น๋์ด ์์ต๋๋ค.".colorize(:green)
|
57
|
+
else
|
58
|
+
puts "๐ฆ GitHub CLI๋ฅผ ์ค์นํฉ๋๋ค...".colorize(:yellow)
|
59
|
+
system("brew install gh")
|
60
|
+
puts "โ
GitHub CLI ์ค์น ์๋ฃ.".colorize(:green)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def check_github_auth
|
65
|
+
auth_status = `gh auth status 2>&1`
|
66
|
+
|
67
|
+
unless $?.success?
|
68
|
+
puts "๐ GitHub ๋ก๊ทธ์ธ์ด ํ์ํฉ๋๋ค.".colorize(:yellow)
|
69
|
+
puts "๋ค์ ๋ช
๋ น์ด๋ฅผ ์คํํ์ฌ ๋ก๊ทธ์ธํด์ฃผ์ธ์:".colorize(:yellow)
|
70
|
+
puts "gh auth login".colorize(:cyan)
|
71
|
+
exit 1
|
72
|
+
end
|
73
|
+
|
74
|
+
# ํ ํฐ ๋ง๋ฃ ํ์ธ
|
75
|
+
if auth_status.include?("Token has expired") || auth_status.include?("authentication failed")
|
76
|
+
puts "โ ๏ธ GitHub ํ ํฐ์ด ๋ง๋ฃ๋์์ต๋๋ค.".colorize(:yellow)
|
77
|
+
puts "๋ค์ ๋ก๊ทธ์ธํด์ฃผ์ธ์:".colorize(:yellow)
|
78
|
+
puts "gh auth login".colorize(:cyan)
|
79
|
+
exit 1
|
80
|
+
end
|
81
|
+
|
82
|
+
puts "โ
GitHub์ ๋ก๊ทธ์ธ๋์ด ์์ต๋๋ค.".colorize(:green)
|
83
|
+
end
|
84
|
+
|
85
|
+
def check_container_registry_permission
|
86
|
+
scopes = `gh auth status -t 2>&1`
|
87
|
+
|
88
|
+
# ํ ํฐ ๋ง๋ฃ ํ์ธ (๊ถํ ์ฒดํฌ ์์๋)
|
89
|
+
if scopes.include?("Token has expired") || scopes.include?("authentication failed")
|
90
|
+
puts "โ ๏ธ GitHub ํ ํฐ์ด ๋ง๋ฃ๋์์ต๋๋ค.".colorize(:yellow)
|
91
|
+
puts "๋ค์ ๋ก๊ทธ์ธํด์ฃผ์ธ์:".colorize(:yellow)
|
92
|
+
puts "gh auth login".colorize(:cyan)
|
93
|
+
exit 1
|
94
|
+
end
|
95
|
+
|
96
|
+
unless scopes.include?("write:packages") || scopes.include?("admin:packages")
|
97
|
+
puts "โ ๏ธ ์ปจํ
์ด๋ ๋ ์ง์คํธ๋ฆฌ ๊ถํ์ด ์์ต๋๋ค.".colorize(:yellow)
|
98
|
+
puts "\nTayo๊ฐ ์ ์ ์๋ํ๊ธฐ ์ํด ๋ค์ ๊ถํ๋ค์ด ํ์ํฉ๋๋ค:".colorize(:yellow)
|
99
|
+
puts "โข repo - GitHub ์ ์ฅ์ ์์ฑ ๋ฐ ๊ด๋ฆฌ".colorize(:yellow)
|
100
|
+
puts "โข read:org - ์กฐ์ง ์ ๋ณด ์ฝ๊ธฐ".colorize(:yellow)
|
101
|
+
puts "โข write:packages - Docker ์ด๋ฏธ์ง๋ฅผ Container Registry์ ํธ์".colorize(:yellow)
|
102
|
+
puts "\nํ ํฐ ์์ฑ ํ์ด์ง๋ฅผ ์ฝ๋๋ค...".colorize(:cyan)
|
103
|
+
|
104
|
+
project_name = File.basename(Dir.pwd)
|
105
|
+
token_description = "Tayo%20-%20#{project_name}"
|
106
|
+
token_url = "https://github.com/settings/tokens/new?scopes=repo,read:org,write:packages&description=#{token_description}"
|
107
|
+
system("open '#{token_url}'")
|
108
|
+
|
109
|
+
puts "\nโ
๋ธ๋ผ์ฐ์ ์์ GitHub ํ ํฐ ์์ฑ ํ์ด์ง๊ฐ ์ด๋ ธ์ต๋๋ค.".colorize(:green)
|
110
|
+
puts "๐ ํ์ํ ๊ถํ๋ค์ด ์ด๋ฏธ ์ฒดํฌ๋์ด ์์ต๋๋ค:".colorize(:green)
|
111
|
+
puts " โข repo - ์ ์ฅ์ ์์ฑ ๋ฐ ๊ด๋ฆฌ".colorize(:gray)
|
112
|
+
puts " โข read:org - ์กฐ์ง ์ ๋ณด ์ฝ๊ธฐ".colorize(:gray)
|
113
|
+
puts " โข write:packages - Container Registry ์ ๊ทผ".colorize(:gray)
|
114
|
+
|
115
|
+
puts "\n๋ค์ ๋จ๊ณ๋ฅผ ๋ฐ๋ผ์ฃผ์ธ์:".colorize(:yellow)
|
116
|
+
puts "1. ํ์ด์ง ํ๋จ์ 'Generate token' ๋ฒํผ์ ํด๋ฆญํ์ธ์".colorize(:cyan)
|
117
|
+
puts "2. ์์ฑ๋ ํ ํฐ์ ๋ณต์ฌํ์ธ์".colorize(:cyan)
|
118
|
+
puts "3. ์๋์ ํ ํฐ์ ๋ถ์ฌ๋ฃ์ผ์ธ์:".colorize(:cyan)
|
119
|
+
|
120
|
+
print "\nํ ํฐ ์
๋ ฅ: ".colorize(:yellow)
|
121
|
+
token = STDIN.gets.chomp
|
122
|
+
|
123
|
+
if token.empty?
|
124
|
+
puts "โ ํ ํฐ์ด ์
๋ ฅ๋์ง ์์์ต๋๋ค.".colorize(:red)
|
125
|
+
exit 1
|
126
|
+
end
|
127
|
+
|
128
|
+
# ํ ํฐ์ ์์ ํ์ผ์ ์ ์ฅํ๊ณ gh auth login ์คํ
|
129
|
+
require 'tempfile'
|
130
|
+
Tempfile.create('github_token') do |f|
|
131
|
+
f.write(token)
|
132
|
+
f.flush
|
133
|
+
|
134
|
+
puts "\n๐ GitHub์ ๋ก๊ทธ์ธ ์ค...".colorize(:yellow)
|
135
|
+
if system("gh auth login --with-token < #{f.path}")
|
136
|
+
puts "โ
GitHub ๋ก๊ทธ์ธ์ ์ฑ๊ณตํ์ต๋๋ค!".colorize(:green)
|
137
|
+
puts "\n๋ค์ 'tayo gh' ๋ช
๋ น์ ์คํํด์ฃผ์ธ์.".colorize(:cyan)
|
138
|
+
else
|
139
|
+
puts "โ GitHub ๋ก๊ทธ์ธ์ ์คํจํ์ต๋๋ค.".colorize(:red)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
exit 0
|
144
|
+
end
|
145
|
+
|
146
|
+
puts "โ
์ปจํ
์ด๋ ๋ ์ง์คํธ๋ฆฌ ๊ถํ์ด ํ์ธ๋์์ต๋๋ค.".colorize(:green)
|
147
|
+
end
|
148
|
+
|
149
|
+
def init_git_repo
|
150
|
+
unless Dir.exist?(".git")
|
151
|
+
Git.init(".")
|
152
|
+
puts "โ
Git ์ ์ฅ์๋ฅผ ์ด๊ธฐํํ์ต๋๋ค.".colorize(:green)
|
153
|
+
else
|
154
|
+
puts "โน๏ธ Git ์ ์ฅ์๊ฐ ์ด๋ฏธ ์ด๊ธฐํ๋์ด ์์ต๋๋ค.".colorize(:yellow)
|
155
|
+
end
|
156
|
+
|
157
|
+
git = Git.open(".")
|
158
|
+
|
159
|
+
# HEAD ์ปค๋ฐ์ด ์๋์ง ํ์ธ
|
160
|
+
has_commits = begin
|
161
|
+
git.log.count > 0
|
162
|
+
rescue Git::GitExecuteError
|
163
|
+
false
|
164
|
+
end
|
165
|
+
|
166
|
+
# git status๋ก ๋ณ๊ฒฝ์ฌํญ ํ์ธ (HEAD๊ฐ ์์ผ๋ฉด ๋ค๋ฅธ ๋ฐฉ๋ฒ ์ฌ์ฉ)
|
167
|
+
has_changes = if has_commits
|
168
|
+
git.status.untracked.any? || git.status.changed.any?
|
169
|
+
else
|
170
|
+
# HEAD๊ฐ ์์ ๋๋ ์ํน ๋๋ ํ ๋ฆฌ์ ํ์ผ์ด ์๋์ง ํ์ธ
|
171
|
+
Dir.glob("*", File::FNM_DOTMATCH).reject { |f| f == "." || f == ".." || f == ".git" }.any?
|
172
|
+
end
|
173
|
+
|
174
|
+
if has_changes
|
175
|
+
git.add(all: true)
|
176
|
+
git.commit("init")
|
177
|
+
puts "โ
์ด๊ธฐ ์ปค๋ฐ์ ์์ฑํ์ต๋๋ค.".colorize(:green)
|
178
|
+
else
|
179
|
+
puts "โน๏ธ ์ปค๋ฐํ ๋ณ๊ฒฝ์ฌํญ์ด ์์ต๋๋ค.".colorize(:yellow)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def create_github_repository
|
184
|
+
repo_name = File.basename(Dir.pwd)
|
185
|
+
username = `gh api user -q .login`.strip
|
186
|
+
|
187
|
+
# ์กฐ์ง ๋ชฉ๋ก ๊ฐ์ ธ์ค๊ธฐ
|
188
|
+
orgs_json = `gh api user/orgs -q '.[].login' 2>/dev/null`
|
189
|
+
orgs = orgs_json.strip.split("\n").reject(&:empty?)
|
190
|
+
|
191
|
+
owner = username
|
192
|
+
|
193
|
+
if orgs.any?
|
194
|
+
prompt = TTY::Prompt.new
|
195
|
+
choices = ["#{username} (๊ฐ์ธ ๊ณ์ )"] + orgs.map { |org| "#{org} (์กฐ์ง)" }
|
196
|
+
|
197
|
+
selection = prompt.select("๐ข ์ ์ฅ์๋ฅผ ์์ฑํ ์์น๋ฅผ ์ ํํ์ธ์:", choices)
|
198
|
+
|
199
|
+
if selection != "#{username} (๊ฐ์ธ ๊ณ์ )"
|
200
|
+
owner = selection.split(" ").first
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
# ์ ์ฅ์ ์กด์ฌ ์ฌ๋ถ ํ์ธ
|
205
|
+
repo_exists = system("gh repo view #{owner}/#{repo_name}", out: File::NULL, err: File::NULL)
|
206
|
+
|
207
|
+
if repo_exists
|
208
|
+
puts "โน๏ธ GitHub ์ ์ฅ์๊ฐ ์ด๋ฏธ ์กด์ฌํฉ๋๋ค: https://github.com/#{owner}/#{repo_name}".colorize(:yellow)
|
209
|
+
@repo_name = repo_name
|
210
|
+
@username = owner
|
211
|
+
else
|
212
|
+
create_cmd = if owner == username
|
213
|
+
"gh repo create #{repo_name} --private --source=. --remote=origin --push"
|
214
|
+
else
|
215
|
+
"gh repo create #{owner}/#{repo_name} --private --source=. --remote=origin --push"
|
216
|
+
end
|
217
|
+
|
218
|
+
result = system(create_cmd)
|
219
|
+
|
220
|
+
if result
|
221
|
+
puts "โ
GitHub ์ ์ฅ์๋ฅผ ์์ฑํ์ต๋๋ค: https://github.com/#{owner}/#{repo_name}".colorize(:green)
|
222
|
+
@repo_name = repo_name
|
223
|
+
@username = owner
|
224
|
+
else
|
225
|
+
puts "โ GitHub ์ ์ฅ์ ์์ฑ์ ์คํจํ์ต๋๋ค.".colorize(:red)
|
226
|
+
exit 1
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
def create_container_registry
|
232
|
+
# Docker ์ด๋ฏธ์ง ํ๊ทธ๋ ์๋ฌธ์์ฌ์ผ ํจ
|
233
|
+
registry_url = "ghcr.io/#{@username.downcase}/#{@repo_name.downcase}"
|
234
|
+
@registry_url = registry_url
|
235
|
+
|
236
|
+
puts "โ
์ปจํ
์ด๋ ๋ ์ง์คํธ๋ฆฌ๊ฐ ์ค์ ๋์์ต๋๋ค.".colorize(:green)
|
237
|
+
puts " URL: #{registry_url}".colorize(:gray)
|
238
|
+
puts " โน๏ธ ์ปจํ
์ด๋ ๋ ์ง์คํธ๋ฆฌ๋ ์ฒซ ์ด๋ฏธ์ง ํธ์ ์ ์๋์ผ๋ก ์์ฑ๋ฉ๋๋ค.".colorize(:gray)
|
239
|
+
|
240
|
+
# Docker๋ก GitHub Container Registry์ ๋ก๊ทธ์ธ
|
241
|
+
puts "\n๐ณ Docker๋ก GitHub Container Registry์ ๋ก๊ทธ์ธํฉ๋๋ค...".colorize(:yellow)
|
242
|
+
|
243
|
+
# ํ์ฌ GitHub ํ ํฐ ๊ฐ์ ธ์ค๊ธฐ
|
244
|
+
token = `gh auth token`.strip
|
245
|
+
|
246
|
+
if token.empty?
|
247
|
+
puts "โ GitHub ํ ํฐ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค.".colorize(:red)
|
248
|
+
return
|
249
|
+
end
|
250
|
+
|
251
|
+
# Docker login ์คํ
|
252
|
+
login_cmd = "echo #{token} | docker login ghcr.io -u #{@username} --password-stdin"
|
253
|
+
|
254
|
+
if system(login_cmd)
|
255
|
+
puts "โ
Docker ๋ก๊ทธ์ธ์ ์ฑ๊ณตํ์ต๋๋ค!".colorize(:green)
|
256
|
+
puts " Registry: ghcr.io".colorize(:gray)
|
257
|
+
puts " Username: #{@username}".colorize(:gray)
|
258
|
+
else
|
259
|
+
puts "โ Docker ๋ก๊ทธ์ธ์ ์คํจํ์ต๋๋ค.".colorize(:red)
|
260
|
+
puts " ์๋์ผ๋ก ๋ค์ ๋ช
๋ น์ ์คํํด์ฃผ์ธ์:".colorize(:yellow)
|
261
|
+
puts " docker login ghcr.io".colorize(:cyan)
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
def create_deploy_config
|
266
|
+
config_dir = "config"
|
267
|
+
Dir.mkdir(config_dir) unless Dir.exist?(config_dir)
|
268
|
+
|
269
|
+
if File.exist?("config/deploy.yml")
|
270
|
+
puts "โน๏ธ ๊ธฐ์กด config/deploy.yml ํ์ผ์ ์
๋ฐ์ดํธํฉ๋๋ค.".colorize(:yellow)
|
271
|
+
update_kamal_config
|
272
|
+
else
|
273
|
+
puts "โ
config/deploy.yml ํ์ผ์ ์์ฑํ์ต๋๋ค.".colorize(:green)
|
274
|
+
create_tayo_config
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
private
|
279
|
+
|
280
|
+
def update_kamal_config
|
281
|
+
content = File.read("config/deploy.yml")
|
282
|
+
|
283
|
+
# ์ด๋ฏธ์ง ์ค์ ์
๋ฐ์ดํธ (ghcr.io ์ค๋ณต ์ ๊ฑฐ)
|
284
|
+
# @registry_url์ ์ด๋ฏธ ghcr.io๋ฅผ ํฌํจํ๊ณ ์์ผ๋ฏ๋ก, ๊ทธ๋๋ก ์ฌ์ฉ
|
285
|
+
content.gsub!(/^image:\s+.*$/, "image: #{@registry_url}")
|
286
|
+
|
287
|
+
# registry ์น์
์
๋ฐ์ดํธ
|
288
|
+
if content.include?("registry:")
|
289
|
+
# ๊ธฐ์กด registry ์น์
์์
|
290
|
+
# server ๋ผ์ธ์ด ์ฃผ์์ฒ๋ฆฌ๋์ด ์๋์ง ํ์ธ
|
291
|
+
if content.match?(/^\s*#\s*server:/)
|
292
|
+
content.gsub!(/^\s*#\s*server:\s*.*$/, " server: ghcr.io")
|
293
|
+
elsif content.match?(/^\s*server:/)
|
294
|
+
content.gsub!(/^\s*server:\s*.*$/, " server: ghcr.io")
|
295
|
+
else
|
296
|
+
# server ๋ผ์ธ์ด ์์ผ๋ฉด username ์์ ์ถ๊ฐ
|
297
|
+
content.gsub!(/(\s*username:\s+)/, " server: ghcr.io\n\\1")
|
298
|
+
end
|
299
|
+
# username๋ ์๋ฌธ์๋ก ๋ณํ
|
300
|
+
content.gsub!(/^\s*username:\s+.*$/, " username: #{@username.downcase}")
|
301
|
+
else
|
302
|
+
# registry ์น์
์ถ๊ฐ
|
303
|
+
registry_config = "\n# Container registry configuration\nregistry:\n server: ghcr.io\n username: #{@username.downcase}\n password:\n - KAMAL_REGISTRY_PASSWORD\n"
|
304
|
+
content.gsub!(/^# Credentials for your image host\.\nregistry:.*?^$/m, registry_config)
|
305
|
+
end
|
306
|
+
|
307
|
+
File.write("config/deploy.yml", content)
|
308
|
+
|
309
|
+
# GitHub ํ ํฐ์ Kamal secrets ํ์ผ์ ์ค์
|
310
|
+
setup_kamal_secrets
|
311
|
+
|
312
|
+
puts "โ
Container Registry ์ค์ ์ด ์
๋ฐ์ดํธ๋์์ต๋๋ค:".colorize(:green)
|
313
|
+
puts " โข ์ด๋ฏธ์ง: #{@registry_url}".colorize(:gray)
|
314
|
+
puts " โข ๋ ์ง์คํธ๋ฆฌ ์๋ฒ: ghcr.io".colorize(:gray)
|
315
|
+
puts " โข ์ฌ์ฉ์๋ช
: #{@username}".colorize(:gray)
|
316
|
+
end
|
317
|
+
|
318
|
+
def setup_kamal_secrets
|
319
|
+
# .kamal ๋๋ ํ ๋ฆฌ ์์ฑ
|
320
|
+
Dir.mkdir(".kamal") unless Dir.exist?(".kamal")
|
321
|
+
|
322
|
+
# ํ์ฌ GitHub ํ ํฐ ๊ฐ์ ธ์ค๊ธฐ
|
323
|
+
token_output = `gh auth token 2>/dev/null`
|
324
|
+
|
325
|
+
if $?.success? && !token_output.strip.empty?
|
326
|
+
token = token_output.strip
|
327
|
+
secrets_file = ".kamal/secrets"
|
328
|
+
|
329
|
+
# ๊ธฐ์กด secrets ํ์ผ ์ฝ๊ธฐ (์๋ค๋ฉด)
|
330
|
+
existing_content = File.exist?(secrets_file) ? File.read(secrets_file) : ""
|
331
|
+
|
332
|
+
# KAMAL_REGISTRY_PASSWORD๊ฐ ์ด๋ฏธ ์๋์ง ํ์ธ
|
333
|
+
if existing_content.include?("KAMAL_REGISTRY_PASSWORD")
|
334
|
+
# ๊ธฐ์กด ๊ฐ ์
๋ฐ์ดํธ
|
335
|
+
updated_content = existing_content.gsub(/^KAMAL_REGISTRY_PASSWORD=.*$/, "KAMAL_REGISTRY_PASSWORD=#{token}")
|
336
|
+
else
|
337
|
+
# ์๋ก ์ถ๊ฐ
|
338
|
+
updated_content = existing_content.empty? ? "KAMAL_REGISTRY_PASSWORD=#{token}\n" : "#{existing_content.chomp}\nKAMAL_REGISTRY_PASSWORD=#{token}\n"
|
339
|
+
end
|
340
|
+
|
341
|
+
File.write(secrets_file, updated_content)
|
342
|
+
puts "โ
GitHub ํ ํฐ์ด .kamal/secrets์ ์ค์ ๋์์ต๋๋ค.".colorize(:green)
|
343
|
+
|
344
|
+
# .gitignore์ secrets ํ์ผ ์ถ๊ฐ
|
345
|
+
add_to_gitignore(".kamal/secrets")
|
346
|
+
else
|
347
|
+
puts "โ ๏ธ GitHub ํ ํฐ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค. ์๋์ผ๋ก ์ค์ ํด์ฃผ์ธ์:".colorize(:yellow)
|
348
|
+
puts " echo 'KAMAL_REGISTRY_PASSWORD=your_github_token' >> .kamal/secrets".colorize(:cyan)
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
def add_to_gitignore(file_path)
|
353
|
+
gitignore_file = ".gitignore"
|
354
|
+
|
355
|
+
if File.exist?(gitignore_file)
|
356
|
+
content = File.read(gitignore_file)
|
357
|
+
unless content.include?(file_path)
|
358
|
+
File.write(gitignore_file, "#{content.chomp}\n#{file_path}\n")
|
359
|
+
puts "โ
.gitignore์ #{file_path}๋ฅผ ์ถ๊ฐํ์ต๋๋ค.".colorize(:green)
|
360
|
+
end
|
361
|
+
else
|
362
|
+
File.write(gitignore_file, "#{file_path}\n")
|
363
|
+
puts "โ
.gitignore ํ์ผ์ ์์ฑํ๊ณ #{file_path}๋ฅผ ์ถ๊ฐํ์ต๋๋ค.".colorize(:green)
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
def create_tayo_config
|
368
|
+
deploy_config = {
|
369
|
+
"production" => {
|
370
|
+
"registry" => @registry_url,
|
371
|
+
"repository" => "https://github.com/#{@username}/#{@repo_name}",
|
372
|
+
"server" => {
|
373
|
+
"host" => "your-home-server.local",
|
374
|
+
"user" => "deploy",
|
375
|
+
"port" => 22
|
376
|
+
},
|
377
|
+
"environment" => {
|
378
|
+
"RAILS_ENV" => "production",
|
379
|
+
"RAILS_MASTER_KEY" => "your-master-key"
|
380
|
+
}
|
381
|
+
}
|
382
|
+
}
|
383
|
+
|
384
|
+
File.write("config/deploy.yml", deploy_config.to_yaml)
|
385
|
+
puts " โ ๏ธ ์๋ฒ ์ ๋ณด์ ํ๊ฒฝ ๋ณ์๋ฅผ ์ค์ ํด์ฃผ์ธ์.".colorize(:yellow)
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|