Skip to content

Commit

Permalink
[#510] Add function remove in Keychain to remove keychain in case the…
Browse files Browse the repository at this point in the history
… runner is self-hosted

Add new fastlane lane removeKeychain
Add remove keychain step in github action workflow
Add continue-on-error: true for step remove keychain
  • Loading branch information
ducbm051291 committed Aug 22, 2023
1 parent 123118f commit fa4a681
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/deploy_app_store.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,8 @@ jobs:
${{ env.DSYM_OUTPUT_PATH }}
env:
TAG_TYPE: App_Store

- name: Remove keychain
if: ${{ always() }}
run: bundle exec fastlane removeKeychain
continue-on-error: true
5 changes: 5 additions & 0 deletions .github/workflows/deploy_production_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ jobs:
${{ env.DSYM_OUTPUT_PATH }}
env:
TAG_TYPE: Production_Firebase

- name: Remove keychain
if: ${{ always() }}
run: bundle exec fastlane removeKeychain
continue-on-error: true
5 changes: 5 additions & 0 deletions .github/workflows/deploy_staging_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,8 @@ jobs:
${{ env.DSYM_OUTPUT_PATH }}
env:
TAG_TYPE: Staging_Firebase

- name: Remove keychain
if: ${{ always() }}
run: bundle exec fastlane removeKeychain
continue-on-error: true
5 changes: 5 additions & 0 deletions .github/workflows/test_upload_build_to_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ jobs:
${{ env.DSYM_OUTPUT_PATH }}
env:
TAG_TYPE: Staging_Firebase

- name: Remove keychain
if: ${{ always() }}
run: bundle exec fastlane removeKeychain
continue-on-error: true
5 changes: 5 additions & 0 deletions .github/workflows/test_upload_build_to_test_flight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,8 @@ jobs:
ISSUER_ID: ${{ secrets.ISSUER_ID }}
SKIP_FIREBASE_DSYM: "true"
BUMP_APP_STORE_BUILD_NUMBER: "true"

- name: Remove keychain
if: ${{ always() }}
run: bundle exec fastlane removeKeychain
continue-on-error: true
1 change: 1 addition & 0 deletions fastlane/Constants/Constant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum Constant {
static let projectPath: String = "./\(projectName).xcodeproj"
static let testOutputDirectoryPath = "./fastlane/test_output"
static let infoPlistPath = "\(projectName)/Configurations/Plists/Info.plist"
static let keychainPath = "~/Library/Keychains/\(keychainName)-db"

// MARK: Platform

Expand Down
5 changes: 5 additions & 0 deletions fastlane/Fastfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class Fastfile: LaneFile {
environment: .production
)
}

func removeKeychainLane() {
desc("Delete keychain")
Keychain.remove()
}

// MARK: - Build

Expand Down
11 changes: 11 additions & 0 deletions fastlane/Helpers/Keychain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright © 2022 Nimble. All rights reserved.
//

import Foundation

enum Keychain {

static func create() {
Expand All @@ -17,4 +19,13 @@ enum Keychain {
timeout: 3600
)
}

static func remove() {
guard FileManager.default.fileExists(atPath: Constant.keychainPath) else {
return log(message: "Couldn't find the Keychain")
}
deleteKeychain(
name: .userDefined(Constant.keychainName)
)
}
}

0 comments on commit fa4a681

Please sign in to comment.