Skip to content

Commit e25c1c1

Browse files
fix(fastlane): restrict CI keychain to GitHub Actions only
- Check GITHUB_ACTIONS env in addition to CI to avoid GUI prompts on dev machines - Set default_keychain: false to preserve user's login keychain - Add security set-key-partition-list call so codesign can access keys without prompts - Cleanup function now uses same guard conditions
1 parent 8b3dab5 commit e25c1c1

1 file changed

Lines changed: 22 additions & 13 deletions

File tree

fastlane/Fastfile

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,25 +124,34 @@ def update_tauri_config_version
124124
end
125125

126126
# Setup temporary keychain for CI environments
127+
# Only runs on GitHub Actions (not local CI) to avoid GUI prompts on dev machines
127128
def setup_ci_keychain
128-
if ENV['CI']
129-
create_keychain(
130-
name: CI_KEYCHAIN_NAME,
131-
password: CI_KEYCHAIN_PASSWORD,
132-
default_keychain: true,
133-
unlock: true,
134-
timeout: 3600,
135-
lock_when_sleeps: false,
136-
add_to_search_list: true
137-
)
129+
return unless ENV['CI'] && ENV['GITHUB_ACTIONS']
130+
131+
keychain_path = File.expand_path("~/Library/Keychains/#{CI_KEYCHAIN_NAME}-db")
132+
133+
create_keychain(
134+
name: CI_KEYCHAIN_NAME,
135+
password: CI_KEYCHAIN_PASSWORD,
136+
default_keychain: false, # don't replace user's default keychain
137+
unlock: true,
138+
timeout: 3600,
139+
lock_when_sleeps: false,
140+
add_to_search_list: true
141+
)
142+
143+
# Set partition list so codesign can access keys without GUI prompt
144+
if File.exist?(keychain_path)
145+
sh("security set-key-partition-list -S apple-tool:,apple: -s -k #{CI_KEYCHAIN_PASSWORD.shellescape} #{keychain_path.shellescape}", log: false)
138146
end
139147
end
140148

141149
# Cleanup CI keychain
142150
def cleanup_ci_keychain
143-
if ENV['CI']
144-
delete_keychain(name: CI_KEYCHAIN_NAME) if File.exist?(File.expand_path("~/Library/Keychains/#{CI_KEYCHAIN_NAME}-db"))
145-
end
151+
return unless ENV['CI'] && ENV['GITHUB_ACTIONS']
152+
153+
keychain_path = File.expand_path("~/Library/Keychains/#{CI_KEYCHAIN_NAME}-db")
154+
delete_keychain(name: CI_KEYCHAIN_NAME) if File.exist?(keychain_path)
146155
end
147156

148157
platform :ios do

0 commit comments

Comments
 (0)