Search code examples
androidgitfirebasegithub-actionsfastlane

Fastlane Github Integration - Author Identity Unknown


I'm building out a pipeline to distribute my QA build via app tester using fastlane and git hub actions.

As part of the pipeline, I am also bumping the version code and creating a branch. The fastlane job works fine when run locally e.g. fastlane deploy_firebase_test_build in my terminal. However, when I run this job via Github Actions I get the following error.

FastlaneCore::Interface::FastlaneShellError: [!] Exit status of command 'git commit -am 'Version bump to 106'' was 128 instead of 0.
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

I tried to set the config in my .yml file but I get an error at that point.

Fastfile

default_platform(:android)

platform :android do

    before_all do
        ENV["FIREBASE_LOGIN_CREDENTIALS"] = "fastlane/sandbox_firebase_auth.json"
        ENV["FIREBASE_APP_ID"] = "*******************************"
    end

    #Firebase Distribution
    desc "Submit test build to App Tester"
    lane :deploy_firebase_test_build do |options|

       #Increment version code
       increment_version_code(gradle_file_path: "./app/build.gradle")

       #Build and assemble sandbox debug
       gradle(task: "clean")
       gradle(task: "assemble", flavor: "sandbox", build_type: "debug")


       #Fetch version code from gradle
       new_version = get_version_name(
            gradle_file_path:"./app/build.gradle",
            ext_constant_name:"versionCode"
        )

        # find apk path
         output_path = "./app/build/outputs/apk/sandbox/debug/"
         output_json_path = output_path + "output-metadata.json"
         build_output = load_json(json_path: output_json_path)
         elements = build_output["elements"][0]
         apk_path = output_path + elements["outputFile"]

            firebase_app_distribution(
                    app: ENV["FIREBASE_APP_ID"],
                    apk_path: apk_path,
                    release_notes_file: "sandboxchangelog.txt",                
                    groups_file: "fastlane/groups.txt",
                    service_credentials_file: ENV["FIREBASE_LOGIN_CREDENTIALS"]
              )

                #Checkout new branch with new version code
                sh("git checkout -b 'JIRA-000-Version-Bump-#{new_version}'")

                #Create commit with new version code
                sh "git commit -am 'Version bump to #{new_version}'"

                #Push commit
                push_to_git_remote
           end
         end

.YML File

name: Build and Distribute - Manual

on:
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - run: git config --global user.name "*********"
    - run: git config --global user.email "**************"

    - name: Set up Ruby Environment
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: '2.7.2'
        bundler-cache: true

    - name: Install bundle
      run: |
        bundle config path vendor/bundle
        bundle install --jobs 4 --retry 3
      
    - name: Create Firebase Service Credentials file
      run: |
        echo "$FIREBASE_CREDENTIALS" > firebase_credentials.json.b64
        base64 -d -i firebase_credentials.json.b64 > firebase_credentials.json
      env:
        FIREBASE_CREDENTIALS: ${{ secrets.FIREBASE_SANDBOX_CREDENTIALS }}
      
    - name: Distribute Sanbox via Apptester
      run: bundle exec fastlane deploy_firebase_test_build
      env:
        FIREBASE_APP_ID: ${{ secrets.SANDBOX_APP_ID }}
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

I am quite new to fastlane and github actions. Can anyone help me out here and steer me in the right direction or can anyone tell me what I need to do in order to fix this issue?

Thanks in advance


Solution

  • You have to place the suggested git config lines just before the command that gave the message in your remote build, that is before sh "git commit -am 'Version bump to #{new_version}'" and after #Create commit with new version code. Otherwise it is easy to get out of context:

                    #Checkout new branch with new version code
                    sh("git checkout -b 'JIRA-000-Version-Bump-#{new_version}'")
    
                    #Create commit with new version code
                    sh "git config --global user.email '[email protected]'"
                    sh "git config --global user.name 'Your Name'"
                    sh "git commit -am 'Version bump to #{new_version}'"
    
                    #Push commit
                    push_to_git_remote
    

    This also has the benefit that you control these properties of the new version code commit next to its message in the Fastfile and you can easily bind them as build properties (not shown in the example as not the main point and should be relatively clear given the Fastfile in question, otherwise comment).