diff --git a/.github/workflows/test_upload_build_to_firebase.yml b/.github/workflows/test_upload_build_to_firebase.yml index 39194acd..3961e6fb 100644 --- a/.github/workflows/test_upload_build_to_firebase.yml +++ b/.github/workflows/test_upload_build_to_firebase.yml @@ -50,7 +50,7 @@ jobs: run: sh make.sh --bundle-id co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --project-name TemplateApp --interface UIKit - name: Start Setup Script for Template App Firebase Upload - run: sh set_up_test_firebase.sh + run: cat Scripts/Swift/SetUpTestFirebase.swift Scripts/Swift/Extensions/FileManager+Utils.swift Scripts/Swift/Helpers/SafeShell.swift | swift - env: MATCH_REPO: ${{ secrets.MATCH_REPO }} STAGING_FIREBASE_APP_ID: ${{ secrets.STAGING_FIREBASE_APP_ID }} diff --git a/Scripts/Swift/SetUpTestFirebase.swift b/Scripts/Swift/SetUpTestFirebase.swift index dc4bc803..59664037 100644 --- a/Scripts/Swift/SetUpTestFirebase.swift +++ b/Scripts/Swift/SetUpTestFirebase.swift @@ -1,18 +1,18 @@ -static let ConstantTeamId = "<#teamId#>" -static let ConstantStagingFirebaseAppId = "<#stagingFirebaseAppId#>" -static let ConstantFirebaseTesterGroups = "<#group1#>, <#group2#>" -static let ConstantMatchRepo = "git@github.com:{organization}\/{repo}.git" +let ConstantTeamId = "<#teamId#>" +let ConstantStagingFirebaseAppId = "<#stagingFirebaseAppId#>" +let ConstantFirebaseTesterGroups = "<#group1#>, <#group2#>" +let ConstantMatchRepo = "git@github.com:{organization}\\/{repo}.git" -let envMatchRepo = ProcessInfo.processInfo.environment["MATCH_REPO"] -let envStagingFirebaseAppId = ProcessInfo.processInfo.environment["STAGING_FIREBASE_APP_ID"] -let envTeamId = ProcessInfo.processInfo.environment["TEAM_ID"] -let matchRepoEscaped = envMatchRepo.replacingOccurrences(of: "/", with: "\/") +let envMatchRepo = ProcessInfo.processInfo.environment["MATCH_REPO"] ?? "" +let envStagingFirebaseAppId = ProcessInfo.processInfo.environment["STAGING_FIREBASE_APP_ID"] ?? "" +let envTeamId = ProcessInfo.processInfo.environment["TEAM_ID"] ?? "" +let matchRepoEscaped = envMatchRepo.replacingOccurrences(of: "/", with: "\\/") let firebaseTesterGroup = "nimble" let fileManager = FileManager.default -let workingDirectory = fileManager.currentDirectoryPath +let workingDirectory = fileManager.currentDirectoryPath.replacingOccurrences(of: "/", with: "\\/") -try? safeShell("LC_ALL=C find \(workingDirectory) -type f -exec sed -i \"\" \"s/\(ConstantTeamId)/\(envTeamId)/g\" {} +") -try? safeShell("LC_ALL=C find \(workingDirectory) -type f -exec sed -i \"\" \"s/\(ConstantStagingFirebaseAppId)/\(envStagingFirebaseAppId)/g\" {} +") -try? safeShell("LC_ALL=C find \(workingDirectory) -type f -exec sed -i \"\" \"s/\(ConstantFirebaseTesterGroups)/\(firebaseTesterGroup)/g\" {} +") -try? safeShell("LC_ALL=C find \(workingDirectory) -type f -exec sed -i \"\" \"s/\(ConstantMatchRepo)/\(matchRepoEscaped)/g\" {} +") +try safeShell("LC_ALL=C find \(workingDirectory) -type f -exec sed -i \"\" \"s/\(ConstantTeamId)/\(envTeamId)/g\" {} +") +try safeShell("LC_ALL=C find \(workingDirectory) -type f -exec sed -i \"\" \"s/\(ConstantStagingFirebaseAppId)/\(envStagingFirebaseAppId)/g\" {} +") +try safeShell("LC_ALL=C find \(workingDirectory) -type f -exec sed -i \"\" \"s/\(ConstantFirebaseTesterGroups)/\(firebaseTesterGroup)/g\" {} +") +try safeShell("LC_ALL=C find \(workingDirectory) -type f -exec sed -i \"\" \"s/\(ConstantMatchRepo)/\(matchRepoEscaped)/g\" {} +") diff --git a/make.sh b/make.sh index 3f8b6ef3..542b8740 100644 --- a/make.sh +++ b/make.sh @@ -215,7 +215,6 @@ git reset if [[ -z "${CI}" ]]; then rm -rf fastlane/Tests - rm -f set_up_test_firebase.sh rm -f set_up_test_testflight.sh cat Scripts/Swift/SetUpCICDService.swift Scripts/Swift/Extensions/FileManager+Utils.swift Scripts/Swift/Helpers/SafeShell.swift > t.swift && swift t.swift && rm -rf 't.swift' cat Scripts/Swift/SetUpDeliveryConstants.swift Scripts/Swift/Extensions/FileManager+Utils.swift Scripts/Swift/Helpers/SafeShell.swift > t.swift && swift t.swift && rm -rf 't.swift' diff --git a/set_up_test_firebase.sh b/set_up_test_firebase.sh deleted file mode 100644 index e551f565..00000000 --- a/set_up_test_firebase.sh +++ /dev/null @@ -1,12 +0,0 @@ -readonly CONSTANT_TEAM_ID="<#teamId#>" -readonly CONSTANT_STAGING_FIREBASE_APP_ID="<#stagingFirebaseAppId#>" -readonly CONSTANT_FIREBASE_TESTER_GROUPS="<#group1#>, <#group2#>" -readonly CONSTANT_MATCH_REPO="git@github.com:{organization}\/{repo}.git" - -readonly WORKING_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P) -MATCH_REPO_ESCAPED=$(echo "${MATCH_REPO//\//\\\/}") - -LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_TEAM_ID/$TEAM_ID/g" {} + -LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_STAGING_FIREBASE_APP_ID/$STAGING_FIREBASE_APP_ID/g" {} + -LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_FIREBASE_TESTER_GROUPS/nimble/g" {} + -LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_MATCH_REPO/$MATCH_REPO_ESCAPED/g" {} +