Github Actions expo upload:ios returning Invalid credentials

Viewed 907

I've set up GitHub actions to build and upload my iOS binary using expo cli.

When run expo build:ios, it works fine.

When run expo upload:ios it shows the following error :

Run expo upload:ios --latest --apple-id=*** --apple-id-password=***
[06:48:59] Downloading build from https://exp-shell-app-assets.s3.us-west-1.amazonaws.com/ios/%40jucasoliveira/cluster-stack-App-413c0004-9f15-43c0-8b79-9748107c9c80-archive.ipa

[06:49:07] Resolving the ITC team ID...
[06:49:10] Failed to upload the standalone app to the app store.
[06:49:10] Invalid Apple ID credentials
[06:49:10] Error: Invalid Apple ID credentials
    at runFastlaneAsync (/Users/runner/hostedtoolcache/expo-cli/3.22.3/x64/node_modules/expo-cli/src/commands/upload/utils.ts:89:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at IOSUploader._uploadToTheStore (/Users/runner/hostedtoolcache/expo-cli/3.22.3/x64/node_modules/expo-cli/src/commands/upload/IOSUploader.ts:197:40)
    at IOSUploader.upload (/Users/runner/hostedtoolcache/expo-cli/3.22.3/x64/node_modules/expo-cli/src/commands/upload/BaseUploader.ts:33:5)
    at /Users/runner/hostedtoolcache/expo-cli/3.22.3/x64/node_modules/expo-cli/src/commands/upload.ts:119:9
    at Command.<anonymous> (/Users/runner/hostedtoolcache/expo-cli/3.22.3/x64/node_modules/expo-cli/src/exp.ts:80:7)
##[error]Process completed with exit code 1.

When I build and upload iOS binaries using expo cli on my local machine , it works properly.

The worflow.yml

name: Expo Publish
on:
  push:
    branches:
      - master
jobs:
  build:
    name: Install and publish
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12.x
      - uses: expo/expo-github-action@v5
        with:
          expo-version: 3.x
          expo-username: ${{ secrets.EXPO_CLI_USERNAME }}
          expo-password: ${{ secrets.EXPO_CLI_PASSWORD }}
      - run: yarn install
      - run: expo build:ios -t archive
      - run: expo build:android -t app-bundle
  deploy_apple:
    needs: build
    name: Deploying to Testflight
    runs-on: macOS-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v1
      - name: Install gpg
        run: brew install gnupg
      - uses: expo/expo-github-action@v5
        with:
          expo-version: 3.x
          expo-username: ${{ secrets.EXPO_CLI_USERNAME }}
          expo-password: ${{ secrets.EXPO_CLI_PASSWORD }}
      - run: expo upload:ios --latest --apple-id=${{ secrets.APPLE_ID_USERNAME}} --apple-id-password=${{ secrets.APPLE_ID_PASSWORD }}
2 Answers

I'm having the exact same issue running expo upload:ios from Github Actions. expo build:ios works fine and expo upload:ios works fine for me locally, but I can't get it to work in actions.

Two Factor Auth Issue

The problem is that if I use my apple-id and apple-id-password that are associated with my Apple account, I run into 2FA issues:

- name: Deploy to Testflight
  run: expo upload:ios --apple-id $EXPO_APPLE_ID --apple-id-password $EXPO_APPLE_PASSWORD
  env:
    EXPO_APPLE_ID: ${{secrets.EXPO_APPLE_ID}}
    EXPO_APPLE_PASSWORD: ${{secrets.EXPO_APPLE_ID_PASSWORD}}

Using my username and password, the app store recognizes me, but it then sends me a code on my phone that I am supposed to enter via stdin. I can't do that with Github actions. This is the resulting output:

[00:29:50] Resolving the ITC team ID...
Two-factor Authentication (6 digits code) is enabled for account '***'
More information about Two-factor Authentication: https://support.apple.com/en-us/HT204915

If you're running this in a non-interactive session (e.g. server or CI)
check out https://github.com/fastlane/fastlane/tree/master/spaceship#2-step-verification

(Input `sms` to escape this prompt and select a trusted phone number to send the code as a text message)

(You can also set the environment variable `SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER` to automate this)
(Read more at: https://github.com/fastlane/fastlane/blob/master/spaceship/docs/Authentication.md#auto-select-sms-via-spaceship_2fa_sms_default_phone_number)

Please enter the 6 digit code:
[00:29:53] Failed to upload the standalone app to the app store.
[00:29:53] The input stream is exhausted.

App Specific Password

So the solution for CI is to use an app specific password. I created an app specific password, and just to be sure everything is was working ok I ran expo upload:ios --apple-id --apple-id-password locally on my mac and it worked, it uploaded my last build to TestFlight. (Assume the are the correct id and password). I hard coded them into the command just to be sure.

So, for some reason, when I run the exact same command with the exact same App Specific Password in Github, I get an error saying invalid apple id credentials:

run: expo upload:ios --apple-id  --apple-id-password 

This is what the output on Github Actions looks like:

Run expo upload:ios --apple-id  --apple-id-password 
[20:15:57] Accessing credentials for *** in project MacCheese
[20:15:59] Downloading build from https://exp-shell-app-assets.s3.us-west-1.amazonaws.com/ios/%40***/MacCheese-cc930f79-18ac-4e33-937d-771613bcd004-archive.ipa

[20:16:03] Resolving the ITC team ID...
[20:16:07] Failed to upload the standalone app to the app store.
[20:16:07] Invalid Apple ID credentials
[20:16:07] Error: Invalid Apple ID credentials

The reason that I hardcoded the apple-id and apple-id-password into the command, is because I've tried everything. I've tried every combination of environment variable under the sun. I read some stuff on App specific passwords in the error message, so I tried adding more environment variables to make that work too:

- name: Deploy to Testflight
  run: expo upload:ios --apple-id $EXPO_APPLE_ID --apple-id-password $EXPO_APPLE_PASSWORD
  env:
    EXPO_APPLE_ID: ${{secrets.EXPO_APPLE_ID}}
    EXPO_APPLE_PASSWORD: ${{secrets.EXPO_APPLE_ID_PASSWORD}}
    FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.EXPO_APPLE_APP_PASSWORD }}
    APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.EXPO_APPLE_APP_PASSWORD }}

I know I have the correct ID, password, and App Specific password because I updated them a billion times. For some reason the expo upload:ios command with an app specific password will work locally, but not on Github actions.

Any suggestions?

Related