Skip to content

Commit 4ecfd66

Browse files
fix(ios): cleanup CI keychain after workflow completion
Add after_all and error hooks to delete the fastlane_ci keychain when lanes complete or fail. Also add workflow-level cleanup step with `if: always()` as a safety net. Prevents stale keychains from prompting unrelated apps for access on self-hosted runners. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 675feae commit 4ecfd66

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

.github/workflows/build-ios-app.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,11 @@ jobs:
9797
APP_STORE_CONNECT_API_KEY_KEY_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY_ID }}
9898
APP_STORE_CONNECT_API_KEY_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
9999
APP_STORE_CONNECT_API_KEY_KEY: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY }}
100+
101+
- name: Cleanup CI keychain
102+
if: always()
103+
run: |
104+
KEYCHAIN_PATH="$HOME/Library/Keychains/fastlane_ci-db"
105+
if [ -f "$KEYCHAIN_PATH" ]; then
106+
security delete-keychain "$KEYCHAIN_PATH" || true
107+
fi

fastlane/Fastfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ def cleanup_ci_keychain
158158
end
159159

160160
platform :ios do
161+
# Cleanup CI keychain after successful lane completion
162+
after_all do |lane|
163+
cleanup_ci_keychain
164+
end
165+
166+
# Cleanup CI keychain on error to prevent stale keychains
167+
error do |lane, exception|
168+
cleanup_ci_keychain
169+
end
170+
161171
desc "Sync code signing certificates"
162172
lane :certificates do
163173
configure_minio

0 commit comments

Comments
 (0)