github actions cant find fastlane folder

26 Views Asked by At

I'm trying to deploy my ionic capacitor app to google play using github actions and fastlane.

This is my workflow:

`
 name: Build Android
    on:
      workflow_dispatch:
    inputs:
      branch:
        description: "Branch to build from"
        required: true
        default: "master"
 jobs:
  build:
    name: Build APK
    runs-on: ubuntu-latest
    steps:
      - name: Setup java
        uses: actions/setup-java@v1
        with:
          java-version: 17.0.8

      - name: Setup Android SDK
        uses: android-actions/setup-android@v3
        
      - name: Checkout source
        uses: actions/checkout@v2        

      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: 3.1.3

      - name: Install Bundler
        run: gem install bundler

      - name: Add current platform to Bundler lockfile
        run: |
          bundle lock --add-platform ruby
          bundle lock --add-platform x86_64-linux

      - name: Setup Node.js
        uses: actions/setup-node@v1
        with:
          node-version: 20.10.0

      - name: Install Ionic
        run: npm install -g @ionic/cli

      - name: Install app dependencies
        run: npm install

      - name: Build Ionic App
        run: ionic build

      - name: Copy Android
        run: ionic capacitor copy android
        
      - name: Build Android Release APK
        run: ionic capacitor build android --release --prod

      # - name: Install Fastlane
      #   run: gem install fastlane

      - name: Decode Service Account Key JSON File
        uses: timheuer/base64-to-file@v1
        id: service_account_json_file
        with:
          fileName: "serviceAccount.json"
          encodedString: ${{ secrets.GPLAY_SERVICE_ACCOUNT_KEY_JSON }}
    
      - name: Decode Keystore File
        uses: timheuer/base64-to-file@v1
        id: android_keystore
        with:
          fileName: "android_keystore.keystore"
          encodedString: ${{ secrets.KEYSTORE_FILE }}

      - name: Install Gems
        run: bundle install
      
      - name: List files in Fastlane folder
        run: |
          if [ -d "fastlane" ]; then
            echo "Files in fastlane folder:"
            ls -l fastlane
          else
            echo "fastlane folder does not exist."
          fi

      - name: Build & deploy Android release
        run: bundle exec fastlane android deploy
        env:
          KEYSTORE_FILE: ${{ steps.android_keystore.outputs.filePath }}
          KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
          KEY_ALIAS: ${{ secrets.KEY_ALIAS}}
          KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
          ANDROID_JSON_KEY_FILE: ${{ steps.service_account_json_file.outputs.filePath }}

      - name: Upload build artifacts
        uses: actions/upload-artifact@v2
        with:
          name: assets
          path: |
            ${{ github.workspace }}/app/build/outputs/bundle/release


 `

On the Build & deploy Android release it can't find my fastlane folder with the fastlane files. I get this error:

`
[21:03:05]: Sending anonymous analytics information
[21:03:05]: Learn more at https://docs.fastlane.tools/#metrics
[21:03:05]: No personal or sensitive data is sent.
[21:03:05]: You can disable this by adding `opt_out_usage` at the top of your Fastfile
[21:03:05]: Could not find fastlane in current directory. Make sure to have your fastlane         configuration files inside a folder called "fastlane". Would you like to set fastlane up?
`

On the step before i run a command to list the files in the fastlane folder if it exists and this is what i get from that command.

Files in fastlane folder: total 16

-rw-r--r-- 1 runner docker  223 Mar 27 20:58 Appfile
-rw-r--r-- 1 runner docker  517 Mar 27 20:58 Matchfile
-rw-r--r-- 1 runner docker 4416 Mar 27 20:58 fastfile

Clearly all the files is in place and they are placed in the fastlane folder just as they are supposed to. So how come fastlane is still complaining about that it can't find the fastlane files?

Here is my fastfile if that helps:

I have tried a lot of different things but i can't make it find the files....

Updated workflow:

name: Build Android
on:
workflow_dispatch:
inputs:
  branch:
    description: "Branch to build from"
    required: true
    default: "master"
jobs:
 build:
name: Build APK
runs-on: ubuntu-latest
 steps:
  - name: Setup java
    uses: actions/setup-java@v1
    with:
      java-version: 17.0.8

  - name: Setup Android SDK
    uses: android-actions/setup-android@v3
    
  - name: Checkout source
    uses: actions/checkout@v2        

  - name: List files in Fastlane folder
    run: |
      if [ -d "fastlane" ]; then
        echo "Files in fastlane folder:"
        ls -l fastlane
      else
        echo "fastlane folder does not exist."
      fi

  - name: Setup Ruby
    uses: ruby/[email protected]
    with:
      ruby-version: 3.1.3
      bundler-cache: true

#  - name: Install Bundler
#    run: gem install bundler

  - name: Add current platform to Bundler lockfile
    run: |
      bundle lock --add-platform ruby
      bundle lock --add-platform x86_64-linux

  - name: Setup Node.js
    uses: actions/setup-node@v1
    with:
      node-version: 20.10.0

  - name: Install Ionic
    run: npm install -g @ionic/cli

  - name: Install app dependencies
    run: npm install

  - name: Build Ionic App
    run: ionic build

  - name: Copy Android
    run: ionic capacitor copy android
    
  - name: Build Android Release APK
    run: ionic capacitor build android --release --prod

  # - name: Install Fastlane
  #   run: gem install fastlane

  - name: Decode Service Account Key JSON File
    uses: timheuer/base64-to-file@v1
    id: service_account_json_file
    with:
      fileName: "serviceAccount.json"
      encodedString: ${{ secrets.GPLAY_SERVICE_ACCOUNT_KEY_JSON }}

  - name: Decode Keystore File
    uses: timheuer/base64-to-file@v1
    id: android_keystore
    with:
      fileName: "android_keystore.keystore"
      encodedString: ${{ secrets.KEYSTORE_FILE }}

 # - name: Install Gems
 #   run: bundle install
  
  - name: List files in Fastlane folder
    run: |
      if [ -d "fastlane" ]; then
        echo "Files in fastlane folder:"
        ls -l fastlane
      else
        echo "fastlane folder does not exist."
      fi

  - name: Build & deploy Android release
    run: bundle exec fastlane android deploy
    env:
      KEYSTORE_FILE: ${{ steps.android_keystore.outputs.filePath }}
      KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
      KEY_ALIAS: ${{ secrets.KEY_ALIAS}}
      KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
      ANDROID_JSON_KEY_FILE: ${{ steps.service_account_json_file.outputs.filePath }}

  - name: Upload build artifacts
    uses: actions/upload-artifact@v2
    with:
      name: assets
      path: |
        ${{ github.workspace }}/app/build/outputs/bundle/release

Now i get this error: Your bundle only supports platforms ["x64-mingw-ucrt"] but your local platform is x86_64-linux. Add the current platform to the lockfile with bundle lock --add-platform x86_64-linux and try again.

Which was the one i managed to solve using this bundle part:

 - name: Add current platform to Bundler lockfile
      run: |
      bundle lock --add-platform ruby
      bundle lock --add-platform x86_64-linux
0

There are 0 best solutions below