souls 1.3.4 → 1.3.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db171a41f8de9bb4f402c769cd2c46dbba8ca747175e70e8a61ae6c8c4298a40
4
- data.tar.gz: b8efa059a87e83ffa2753fe7f91df0df7049fdf64f3f301bdcab73d753458ba1
3
+ metadata.gz: 15b543f68c631153cb55d9db471e72bb9a0a8bf057abfcefb7abe115eb3cad50
4
+ data.tar.gz: dcb2091faf7d1dba574743f119b9019d70fd2544a07f25c46043f6a153827b59
5
5
  SHA512:
6
- metadata.gz: 79a2a2a9f9f8266861cd9363f7299576bd227224a3ef6e78e2e566067b14535547b399862d558eb9133474c8be185e5220e3785a6f6d43c48ac04732864d1a51
7
- data.tar.gz: e434dec7a31f610a65083574e09abefee38b3438b58eb28c4a2dec94c82463d3a4b0ed2b685d3da94061badcfdec72c365f4f8da4dc6b9d473d9524b9b85c910
6
+ metadata.gz: ab28c78e9531eca9678af3a1910ae2436f2ea0739729f235516fb248f109f4511581f4dfeb0602c5c25b7d69522e7d128db8816bd8ba81b9ce7df664a6592d1a
7
+ data.tar.gz: c56cbdd2485dfc68d08f74147a5cba66cc388a32c2fc1c74fe3c0affde2385b1d9ed8b94f2fbe448d8441656e3c9c237ecb71a0a2a9216630fe31f5ca5cbc6bd
@@ -173,39 +173,38 @@ end
173
173
  uses: google-github-actions/setup-gcloud@master
174
174
  with:
175
175
  version: "323.0.0"
176
- project_id: ${{ secrets.GCP_PROJECT_ID }}
177
- service_account_key: ${{ secrets.GCP_SA_KEY }}
176
+ project_id: ${{ secrets.SOULS_GCP_PROJECT_ID }}
177
+ service_account_key: ${{ secrets.SOULS_GCP_SA_KEY }}
178
178
  export_default_credentials: true
179
179
 
180
180
  - name: Configure Docker
181
181
  run: gcloud auth configure-docker --quiet
182
182
 
183
183
  - name: Build Docker container
184
- run: docker build -f ./apps/#{worker_name}/Dockerfile ./apps/#{worker_name} -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{secrets.APP_NAME}}-#{worker_name}
184
+ run: docker build -f ./apps/#{worker_name}/Dockerfile ./apps/#{worker_name} -t gcr.io/${{ secrets.SOULS_GCP_PROJECT_ID }}/${{secrets.SOULS_APP_NAME}}-#{worker_name}
185
185
 
186
186
  - name: Push to Container Resistory
187
- run: docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{secrets.APP_NAME}}-#{worker_name}
187
+ run: docker push gcr.io/${{ secrets.SOULS_GCP_PROJECT_ID }}/${{secrets.SOULS_APP_NAME}}-#{worker_name}
188
188
 
189
189
  - name: Deploy to Cloud Run
190
190
  run: |
191
- gcloud run deploy souls-${{ secrets.APP_NAME }}-#{worker_name} \\
192
- --service-account=${{ secrets.APP_NAME }}@${{ secrets.GCP_PROJECT_ID }}.iam.gserviceaccount.com \\
193
- --image=gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{secrets.APP_NAME}}-#{worker_name} \\
191
+ gcloud run deploy souls-${{ secrets.SOULS_APP_NAME }}-#{worker_name} \\
192
+ --service-account=${{ secrets.SOULS_APP_NAME }}@${{ secrets.SOULS_GCP_PROJECT_ID }}.iam.gserviceaccount.com \\
193
+ --image=gcr.io/${{ secrets.SOULS_GCP_PROJECT_ID }}/${{secrets.SOULS_APP_NAME}}-#{worker_name} \\
194
194
  --memory=4Gi \\
195
- --region=${{ secrets.GCP_REGION }} \\
195
+ --region=${{ secrets.SOULS_GCP_REGION }} \\
196
196
  --allow-unauthenticated \\
197
197
  --platform=managed \\
198
198
  --quiet \\
199
199
  --concurrency=80 \\
200
200
  --port=8080 \\
201
- --set-cloudsql-instances=${{ secrets.GCLOUDSQL_INSTANCE }} \\
202
- --set-env-vars="DB_USER=${{ secrets.DB_USER }}" \\
203
- --set-env-vars="DB_PW=${{ secrets.DB_PW }}" \\
204
- --set-env-vars="DB_HOST=${{ secrets.DB_HOST }}" \\
205
- --set-env-vars="TZ=${{ secrets.TZ }}" \\
206
- --set-env-vars="SLACK=${{ secrets.SLACK }}" \\
207
- --set-env-vars="SECRET_KEY_BASE=${{ secrets.SECRET_KEY_BASE }}" \\
208
- --set-env-vars="PROJECT_ID=${{ secrets.GCP_PROJECT_ID }}"
201
+ --set-cloudsql-instances=${{ secrets.SOULS_GCLOUDSQL_INSTANCE }} \\
202
+ --set-env-vars="SOULS_DB_USER=${{ secrets.SOULS_DB_USER }}" \\
203
+ --set-env-vars="SOULS_DB_PW=${{ secrets.SOULS_DB_PW }}" \\
204
+ --set-env-vars="SOULS_DB_HOST=${{ secrets.SOULS_DB_HOST }}" \\
205
+ --set-env-vars="SOULS_TZ=${{ secrets.SOULS_TZ }}" \\
206
+ --set-env-vars="SOULS_SECRET_KEY_BASE=${{ secrets.SOULS_SECRET_KEY_BASE }}" \\
207
+ --set-env-vars="SOULS_PROJECT_ID=${{ secrets.SOULS_GCP_PROJECT_ID }}"
209
208
  TEXT
210
209
  end
211
210
  puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
@@ -7,7 +7,6 @@ module Souls
7
7
  def create_instance
8
8
  app_name = Souls.configuration.app
9
9
  project_id = Souls.configuration.project_id
10
- region = Souls.configuration.region
11
10
  instance_name = Souls.configuration.instance_name if instance_name.blank?
12
11
  region = Souls.configuration.region if options[:region].blank?
13
12
  db_type = options[:mysql] ? "MYSQL_8_0" : "POSTGRES_13"
@@ -22,12 +21,12 @@ module Souls
22
21
  file_path = ".env"
23
22
  File.open(file_path, "w") do |line|
24
23
  line.write(<<~TEXT)
25
- DB_HOST=#{get_sql_ip.strip}
26
- DB_PW=#{options[:root_password]}
27
- DB_USER=postgres
28
- SLACK=YOUR_WEB_HOOK_URL
29
- TZ="Asia/Tokyo"
30
- SECRET_KEY_BASE=xxxxxxxxxxxxxx
24
+ SOULS_DB_HOST=#{get_sql_ip.strip}
25
+ SOULS_DB_PW=#{options[:root_password]}
26
+ SOULS_DB_USER=postgres
27
+ SOULS_GCP_PROJECT_ID=#{project_id}
28
+ SOULS_SECRET_KEY_BASE="#{SecureRandom.base64(64)}"
29
+ TZ="#{region_to_timezone(region: region)}"
31
30
  TEXT
32
31
  end
33
32
  end
@@ -35,19 +34,19 @@ module Souls
35
34
  file_path = ".env.production"
36
35
  File.open(file_path, "w") do |line|
37
36
  line.write(<<~TEXT)
38
- DB_HOST="/cloudsql/#{project_id}:#{region}:#{instance_name}"
39
- DB_PW=#{options[:root_password]}
40
- DB_USER=postgres
41
- APP_NAME=#{app_name}
42
- GCP_PROJECT_ID=#{project_id}
43
- GCP_REGION=#{region}
44
- GCLOUDSQL_INSTANCE="#{project_id}:#{region}:#{instance_name}"
45
- TZ="Asia/Tokyo"
46
- SLACK="https://YOUR.WEB_HOOK_URL"
47
- SECRET_KEY_BASE="XXXXXXXSecureTokenXXXXXXXXXX"
37
+ SOULS_DB_HOST="/cloudsql/#{project_id}:#{region}:#{instance_name}"
38
+ SOULS_DB_PW=#{options[:root_password]}
39
+ SOULS_DB_USER=postgres
40
+ SOULS_APP_NAME=#{app_name}
41
+ SOULS_GCP_PROJECT_ID=#{project_id}
42
+ SOULS_GCP_REGION=#{region}
43
+ SOULS_GCLOUDSQL_INSTANCE="#{project_id}:#{region}:#{instance_name}"
44
+ SOULS_SECRET_KEY_BASE="#{SecureRandom.base64(64)}"
45
+ TZ="#{region_to_timezone(region: region)}"
48
46
  TEXT
49
47
  end
50
48
  end
49
+ Souls::Github.new
51
50
  rescue Thor::Error => e
52
51
  raise(Thor::Error, e)
53
52
  end
@@ -136,5 +135,15 @@ module Souls
136
135
  def get_sql_ip
137
136
  `gcloud sql instances list | grep james | awk '{print $5}'`
138
137
  end
138
+
139
+ def region_to_timezone(region: "asia-northeast1")
140
+ if region.include?("asia")
141
+ "Asia/Tokyo"
142
+ elsif region.include?("europe")
143
+ "Europe/Amsterdam"
144
+ else
145
+ "America/Los_Angeles"
146
+ end
147
+ end
139
148
  end
140
149
  end
@@ -1,8 +1,7 @@
1
1
  module Souls
2
2
  class Github < Thor
3
- desc "secret_set", "Github Secret Set by Github CLI"
3
+ desc "secret_set", "Github Secret Set from .env.production"
4
4
  def secret_set
5
- require("#{Souls.get_api_path}/config/souls")
6
5
  file_path = ".env.production"
7
6
  File.open(file_path, "r") do |file|
8
7
  file.each_line do |line|
@@ -11,5 +10,50 @@ module Souls
11
10
  end
12
11
  end
13
12
  end
13
+
14
+ desc "add_env", "Add New env and Sync Github Secret"
15
+ method_option :key, aliases: "--key", required: true, desc: "Key Name"
16
+ method_option :value, aliases: "--value", required: true, desc: "Value Name"
17
+ method_option :dqm, type: :boolean, aliases: "--dqm", default: false, desc: "Enable Double Quotation Mark"
18
+ def add_env
19
+ update_env_production(key: options[:key], value: options[:value], dqm: options[:dqm])
20
+ update_api_env(key: options[:key], value: options[:value], dqm: options[:dqm])
21
+ update_github_actions(key: options[:key])
22
+ Souls::Github.new.invoke(:secret_set)
23
+ end
24
+
25
+ private
26
+
27
+ def update_env_production(key:, value:, dqm: false)
28
+ Dir.chdir(Souls.get_mother_path.to_s) do
29
+ file_path = ".env.production"
30
+ File.open(file_path, "a") do |line|
31
+ dqm ? line.write("\n#{key.upcase}=\"#{value}\"") : line.write("\n#{key.upcase}=#{value}")
32
+ end
33
+ puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
34
+ end
35
+ end
36
+
37
+ def update_api_env(key:, value:, dqm: false)
38
+ Dir.chdir(Souls.get_api_path.to_s) do
39
+ file_path = ".env"
40
+ File.open(file_path, "a") do |line|
41
+ dqm ? line.write("\n#{key.upcase}=\"#{value}\"") : line.write("\n#{key.upcase}=#{value}")
42
+ end
43
+ puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
44
+ end
45
+ end
46
+
47
+ def update_github_actions(key:)
48
+ Dir.chdir(Souls.get_mother_path.to_s) do
49
+ file_paths = Dir[".github/workflows/*.yml"]
50
+ file_paths.each do |file_path|
51
+ File.open(file_path, "a") do |line|
52
+ line.write(" \\ \n --set-env-vars=\"#{key.upcase}=${{ secrets.#{key.upcase} }}\"")
53
+ end
54
+ puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
55
+ end
56
+ end
57
+ end
14
58
  end
15
59
  end
@@ -159,14 +159,13 @@ module Souls
159
159
  system("cd #{app_name} && curl -OL https://storage.googleapis.com/souls-bucket/boilerplates/Procfile")
160
160
  system("cd #{app_name} && curl -OL https://storage.googleapis.com/souls-bucket/boilerplates/Steepfile")
161
161
  system("cd #{app_name} && curl -OL https://storage.googleapis.com/souls-bucket/boilerplates/gitignore")
162
- system("cd #{app_name} && curl -OL https://storage.googleapis.com/souls-bucket/boilerplates/.env.production.sample")
163
162
  system("cd #{app_name} && mv gitignore .gitignore")
164
163
  system("cd #{app_name} && bundle")
165
164
  system("cd #{app_name}/apps/api && bundle")
166
165
  FileUtils.rm(sig_name)
167
166
  end
168
167
 
169
- def souls_api_credit(app_name: "souls", service_name: "api")
168
+ def souls_api_credit(app_name: "souls")
170
169
  line = Paint["====================================", :yellow]
171
170
  puts("\n")
172
171
  puts(line)
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "1.3.4".freeze
2
+ VERSION = "1.3.8".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 1.3.4
1
+ 1.3.8
@@ -1 +1 @@
1
- 1.3.4
1
+ 1.3.8
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: souls
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI