diff --git a/.github/workflows/test_add_device_profile.yml b/.github/workflows/test_add_device_profile.yml new file mode 100644 index 00000000..6a2adaf7 --- /dev/null +++ b/.github/workflows/test_add_device_profile.yml @@ -0,0 +1,51 @@ +name: Test Add device and regenerate profiles with fastlane match + +# SECRETS needed: +### SSH_PRIVATE_KEY for the match Repo +### MATCH_PASSWORD + +on: + workflow_dispatch: + inputs: + devices: + description: 'JSON of devices. `{"Luka iPhone 6": "1234567890123456789012345678901234567890","Felix iPad Air 2": "abcdefghijklmnopqrstvuwxyzabcdefghijklmn"}`' + required: true + type: string + platform: + description: 'The platform' + required: true + default: 'ios' + type: choice + options: + - ios + - mac + +jobs: + create_files: + name: Create certificates and profiles + runs-on: [self-hosted, macOS] + steps: + - name: Checkout the repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install SSH key + uses: webfactory/ssh-agent@v0.5.4 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Bundle install + run: bundle install + + - name: Add device and regenerate profiles with match + run: bundle exec fastlane addDevicesGenerateProfiles + env: + MATCH_PASSWORD: ${{ secrets.MATCH_PASS }} + DEVICES: ${{ inputs.devices }} + PLATFORM: ${{ inputs.platform }} + + - name: Clean up keychain + if: ${{ always() }} + run: bundle exec fastlane remove_keychain + continue-on-error: true diff --git a/fastlane/Fastfile.swift b/fastlane/Fastfile.swift index 5052b7ad..16d35965 100644 --- a/fastlane/Fastfile.swift +++ b/fastlane/Fastfile.swift @@ -176,6 +176,26 @@ class Fastfile: LaneFile { Match.syncCodeSigning(type: .adHoc, environment: .staging, isForce: true) } + func addDevicesGenerateProfiles(withOptions options:[String: String]?) { + desc("Add device and regenerate profiles with match") + + guard + let json = options?["devices"], + let devices = SocketResponse.convertToDictionary(text: json), + let platform = options?["devices_type"] else { + return + } + + registerDevices( + devices: .userDefined(devices), + teamId: .userDefined(Constant.appleStagingTeamId), + platform: platform + ) + + Match.syncCodeSigning(type: .development, environment: .staging, isForce: true) + Match.syncCodeSigning(type: .adHoc, environment: .staging, isForce: true) + } + // MARK: - Utilities func cleanUpOutputLane() {