Skip to content

Commit

Permalink
[#498] Update Script: SetUpCICDService to ask for runner type
Browse files Browse the repository at this point in the history
Update RUNNER_TYPE constant to replace in github workflows
  • Loading branch information
ducbm051291 committed Nov 15, 2023
1 parent 54c98ee commit e914448
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:
jobs:
review_pull_request:
name: Pull request review by Danger
runs-on: macOS-latest
runs-on: {RUNNER_TYPE}
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/project_workflows/deploy_app_store.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

build:
name: Build
runs-on: macOS-latest
runs-on: {RUNNER_TYPE}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/project_workflows/deploy_production_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

build:
name: Build
runs-on: macOS-latest
runs-on: {RUNNER_TYPE}
steps:
- uses: actions/checkout@v3
# Set fetch-depth (default: 1) to get whole tree
Expand Down
2 changes: 1 addition & 1 deletion .github/project_workflows/deploy_staging_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

build:
name: Build
runs-on: macOS-latest
runs-on: {RUNNER_TYPE}
steps:
- uses: actions/checkout@v3
# Set fetch-depth (default: 1) to get whole tree
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_uikit_install_script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:
jobs:
Test:
name: Test
runs-on: macOS-latest
runs-on: {RUNNER_TYPE}
steps:
- uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_upload_build_to_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ concurrency:
jobs:
build:
name: Build
runs-on: macOS-latest
runs-on: {RUNNER_TYPE}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_upload_build_to_test_flight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ concurrency:
jobs:
build:
name: Build
runs-on: macOS-latest
runs-on: {RUNNER_TYPE}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct SetUpCICDService {
}
}

private let CONSTANT_RUNNER_TYPE = "{RUNNER_TYPE}"
private let fileManager = FileManager.default

func perform() {
Expand All @@ -40,6 +41,30 @@ struct SetUpCICDService {
fileManager.createDirectory(path: ".github/workflows")
fileManager.moveFiles(in: ".github/project_workflows", to: ".github/workflows")
fileManager.removeItems(in: ".github/project_workflows")
fileManager.moveFiles(in: ".github/project_workflows", to: ".github/workflows")
fileManager.removeItems(in: ".github/project_workflows")

var runnerType: String?
var runnerName: String = ""
while runnerType == nil {
print("Which workflow runner do you want to use? [(m)acos-latest/(s)elf-hosted]: ")
runnerType = readLine()?.lowercased()
if runnerType != "m" && runnerType != "s" {
print("Invalid input. Please enter 'm' for macOS-latest or 's' for self-hosted.")
runnerType = nil
}
}

// Use the selected runnerType to configure the workflow
if runnerType == "s" {
print("Configuring workflow for self-hosted runner")
runnerName = "[self-hosted, macOS]"
} else {
print("Configuring workflow for macOS-latest")
runnerName = "macOS-latest"
}

fileManager.replaceAllOccurrences(of: CONSTANT_RUNNER_TYPE, to: runnerName)
case .bitrise:
print("Setting template for Bitrise")
fileManager.removeItems(in: "codemagic.yaml")
Expand Down

0 comments on commit e914448

Please sign in to comment.