wzieba / Firebase-Distribution-Github-Action

This action uploads artifacts (.apk or .ipa) to Firebase App Distribution.
MIT License
358 stars 75 forks source link

Unable to parse JSON uploading apk #134

Open rvanderlinden opened 1 month ago

rvanderlinden commented 1 month ago

Hi,

I'm trying to use this action in a reusable workflow to upload an apk to Firebase App Distribution. Unfortunately I keep getting an issue.

The error (if I set debug: true there is no additional output):

i  uploading binary...

Error: failed to upload release. Unable to parse JSON: SyntaxError: Unexpected token < in JSON at position 0

The action in use:

      - name: Deploy to Firebase App Distribution.
        uses: wzieba/Firebase-Distribution-Github-Action@v1
        with:
          # The app ID in format 1:123:android:123abc123abc123 as taken from Firebase under Your Apps.
          appId: ${{ secrets.ANDROID_FIREBASE_APP_ID }}
          # The copied content of the private JSON key associated with the Service Account in the Google Cloud Console for this project, that has the Firebase App Distribution Admin role.
          serviceCredentialsFileContent: ${{ secrets.ANDROID_FIREBASE_SERVICE_ACCOUNT_JSON }}
          # Our test groups
          groups: "test"
          # The artifact to upload, which definitely exists (tested and working for App Center distribution).
          file: "builds/app-production-release.apk"

Considering the error is related to parsing JSON and the serviceCredentialsFileContent is the only JSON submitted by me, I validated the service account, the key and the secrets. I have a similar setup for Play Store distribution (with a private JSON key) that is working so I'm unsure what I'd be doing wrong here.

That brings me to my question: Is there any way I could get more information about the cause of the problem? I feel like the error Unexpected token < in JSON at position 0 is not related to the serviceCredentialsFileContent, but I need more feedback to validate that. Any ideas how I can move forward? Thanks!

Edit: I noticed on another issue that this error may be related to a very large apk, which is not the case here (about 10 MB).

Full workflow:

on:
  workflow_call:

   # inputs redacted for brevity

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: ${{ inputs.github-environment }}
    steps:

      - name: Fetch project from remote.
        uses: actions/checkout@v4

      - name: Download artifact '${{ inputs.app-artifact-download-filename }}'.
        uses: actions/download-artifact@v4
        with:
          name: ${{ inputs.app-artifact-download-filename }}
          path: ./builds

      - name: Deploy to Firebase App Distribution.
        uses: wzieba/Firebase-Distribution-Github-Action@v1
        with:
          appId: ${{ secrets.ANDROID_FIREBASE_APP_ID }}
          serviceCredentialsFileContent: ${{ secrets.ANDROID_FIREBASE_SERVICE_ACCOUNT_JSON }}
          groups: "test"
          file: "./builds/app-production-release.apk"
rvanderlinden commented 1 month ago

I have made some progress since:

Can this be related to file access permissions somehow?

rvanderlinden commented 1 month ago

Unfortunately I was not able to make any further progress. Instead we decided to try out firebase_app_distribution in Fastlane, which does work with the reusable workflow outlined above.

I'm not sure what is holding back the reusable workflow approach for this action, but if someone thinks they may have a way to resolve it, please let me know so I can try it out. Meanwhile we'll opt for the Fastlane approach.