souls 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/souls/cli/create/index.rb +15 -16
- data/lib/souls/cli/gcloud/sql/index.rb +24 -17
- data/lib/souls/cli/github/index.rb +46 -2
- data/lib/souls/version.rb +1 -1
- data/lib/souls/versions/.souls_api_version +1 -1
- data/lib/souls/versions/.souls_worker_version +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7be84adf2c447eaa2ecd78cd32ca799988aff10a77669daa77323829687f18d
|
4
|
+
data.tar.gz: ce581a1c2d2b42bf657ea74f04076d58820b260c48fabacd46fcb064abadfef4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b0545fb8986cbc81658387264a3d30b545dd01e3a46522dd4b6eeafbaa7f8370969d657d536b9951f10912b1a86897066a65068d045be8e82fe16155c071734
|
7
|
+
data.tar.gz: 1b1e25eaa958bc4a5c02ee0ce0ab9775e63aba4fc26faa2d4bbf22ea0f78d4b0c1ca780cffd581992f71a2bbec5ee10ebfb1d07c18b6781378ab92e4f7ab435e
|
@@ -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.
|
177
|
-
service_account_key: ${{ secrets.
|
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.
|
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.
|
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.
|
192
|
-
--service-account=${{ secrets.
|
193
|
-
--image=gcr.io/${{ secrets.
|
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.
|
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.
|
202
|
-
--set-env-vars="
|
203
|
-
--set-env-vars="
|
204
|
-
--set-env-vars="
|
205
|
-
--set-env-vars="
|
206
|
-
--set-env-vars="
|
207
|
-
--set-env-vars="
|
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,11 @@ module Souls
|
|
22
21
|
file_path = ".env"
|
23
22
|
File.open(file_path, "w") do |line|
|
24
23
|
line.write(<<~TEXT)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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_TZ="#{region_to_timezone(region: region)}"
|
28
|
+
SOULS_SECRET_KEY_BASE="#{SecureRandom.base64(64)}"
|
31
29
|
TEXT
|
32
30
|
end
|
33
31
|
end
|
@@ -35,16 +33,15 @@ module Souls
|
|
35
33
|
file_path = ".env.production"
|
36
34
|
File.open(file_path, "w") do |line|
|
37
35
|
line.write(<<~TEXT)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
SECRET_KEY_BASE="XXXXXXXSecureTokenXXXXXXXXXX"
|
36
|
+
SOULS_DB_HOST="/cloudsql/#{project_id}:#{region}:#{instance_name}"
|
37
|
+
SOULS_DB_PW=#{options[:root_password]}
|
38
|
+
SOULS_DB_USER=postgres
|
39
|
+
SOULS_APP_NAME=#{app_name}
|
40
|
+
SOULS_GCP_PROJECT_ID=#{project_id}
|
41
|
+
SOULS_GCP_REGION=#{region}
|
42
|
+
SOULS_GCLOUDSQL_INSTANCE="#{project_id}:#{region}:#{instance_name}"
|
43
|
+
SOULS_TZ="#{region_to_timezone(region: region)}"
|
44
|
+
SOULS_SECRET_KEY_BASE="#{SecureRandom.base64(64)}"
|
48
45
|
TEXT
|
49
46
|
end
|
50
47
|
end
|
@@ -136,5 +133,15 @@ module Souls
|
|
136
133
|
def get_sql_ip
|
137
134
|
`gcloud sql instances list | grep james | awk '{print $5}'`
|
138
135
|
end
|
136
|
+
|
137
|
+
def region_to_timezone(region: "asia-northeast1")
|
138
|
+
if region.include?("asia")
|
139
|
+
"Asia/Tokyo"
|
140
|
+
elsif region.include?("europe")
|
141
|
+
"Europe/Amsterdam"
|
142
|
+
else
|
143
|
+
"America/Los_Angeles"
|
144
|
+
end
|
145
|
+
end
|
139
146
|
end
|
140
147
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module Souls
|
2
2
|
class Github < Thor
|
3
|
-
desc "secret_set", "Github Secret Set
|
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
|
data/lib/souls/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.5
|
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.5
|