Skip to content

Commit b50edea

Browse files
committed
Read secrets based on environment
1 parent c11a11c commit b50edea

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

Fastlane/Fastfile

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,8 @@ platform :ios do
202202

203203
desc "Uploads DSYM files to Sentry"
204204
lane :upload_dsym_to_sentry do
205-
auth_token = get_xcconfig_value(
206-
path: 'Configs/Secrets.xcconfig',
207-
name: 'SENTRY_DSYM_TOKEN'
208-
)
209-
205+
auth_token = get_secret_value('SENTRY_DSYM_TOKEN')
206+
210207
sentry_debug_files_upload(
211208
auth_token: auth_token,
212209
org_slug: 'forpda',
@@ -290,4 +287,23 @@ def print_lane_options(lane_name, options = {})
290287
default_str = value[:default] ? " (default: #{value[:default]})" : ""
291288
UI.message("• #{key}: #{value[:description]}#{default_str}")
292289
end
293-
end
290+
end
291+
292+
def get_secret_value(name)
293+
is_ci = ENV['CI'] == 'true'
294+
295+
if is_ci
296+
value = ENV[name]
297+
UI.message("Using #{name} from environment (CI=true)")
298+
else
299+
xcconfig_path = 'Configs/Secrets.local.xcconfig'
300+
value = get_xcconfig_value(path: xcconfig_path, name: name)
301+
UI.message("Using #{name} from #{xcconfig_path} (CI=false)")
302+
end
303+
304+
if value.nil? || value.empty?
305+
UI.user_error("Error: #{name} is not set")
306+
end
307+
308+
value
309+
end

0 commit comments

Comments
 (0)