1

I'm trying to deploy an app using Github actions, and I have a lot of issues due to the fact that I have a private pod in my app. I looked at various suggestions how to solve this but none of the answers I found helped me in deploying the app. Here is how my script looks like:

name: deploy

on:
  push:
    branches: [ develop ]
    tags: [ v* ]

jobs:
  deploy:
    runs-on: macos-latest

    steps:
      - name: Checkout project
        uses: actions/checkout@v2

      - name: Set environment variables from project settings
        run: |
          exec .github/scripts/set-env-from-xcodeproj.sh                              

      - name: Import signing certificate
        env:
          SIGNING_CERTIFICATE_P12_DATA: ${{ secrets.SIGNING_CERTIFICATE_P12_DATA }}
          SIGNING_CERTIFICATE_PASSWORD: ${{ secrets.SIGNING_CERTIFICATE_PASSWORD }}
        run: |
          exec .github/scripts/import-certificate.sh

      - name: Import provisioning profile
        env:
          PROVISIONING_PROFILE_DATA: ${{ secrets.PROVISIONING_PROFILE_DATA }}
        run: |
          exec .github/scripts/import-profile.sh

      - name: Credentials setup
        run: |
          git config --global credential.helper store
          echo "https://username:${{ secrets.GIT_TOKEN }}@github.com" > ~/.git-credentials
        
      - name: Dependencies install
        run: |
          pod install

      - name: Build app
        run: |
          fastlane run build_app

      - name: Upload build artifacts
        uses: actions/upload-artifact@v2
        with:
          name: build.log
          path: ~/Library/Logs/gym/*.log

      - name: Upload release assets
        if: startsWith(github.ref, 'refs/tags/v')
        uses: softprops/action-gh-release@v1
        with:
          files: |
            ${{ env.PRODUCT_NAME }}.ipa
            ${{ env.PRODUCT_NAME }}.app.dSYM.zip
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Upload app to App Store Connect
        if: startsWith(github.ref, 'refs/tags/v')
        env:
          APP_STORE_CONNECT_USERNAME: ${{ secrets.APP_STORE_CONNECT_USERNAME }}
          APP_STORE_CONNECT_PASSWORD: ${{ secrets.APP_STORE_CONNECT_PASSWORD }}
        run: |
          xcrun altool --upload-app -t ios -f "$PRODUCT_NAME.ipa" -u "$APP_STORE_CONNECT_USERNAME" -p "$APP_STORE_CONNECT_PASSWORD"

And my podfile:

# Uncomment the next line to define a global platform for your project
platform :ios, '13.0'

source 'https://github.com/organization/privatepod.git'
source 'https://github.com/CocoaPods/Specs.git'

post_install do |installer_representation|
    installer_representation.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
            config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
        end
    end
end
  
target 'Target' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
    
  # Pods for LHTest
  pod 'privatepodname', '~>2.2.6'
  pod 'Firebase/Core'
  pod 'Firebase/Analytics'
  pod 'Firebase/Messaging'
  pod 'Firebase/Crashlytics'
    
end

I get an error saying fatal: Could not read from remote repository. Please make sure you have the correct access rights.

I also tried an approach to manually add the repo via pod repo add command but still get the error. My undersntanding was that the line "Credentials setup" form the script should be enough to authenticate my github account and allow me to install the private repo but it doesn't seem to work.

Nermin Sehic
  • 594
  • 6
  • 22

1 Answers1

0

To authenticate to the private repository you have to use SSH keys rather than https - https is only using keychain password and prompting for user/password if it's not there - it won't work on CI.

Switch to: git@github.com:organization/privatepod.git

Also if you have 2FA enabled (I hope you do) - you need to use a PERSONAL_TOKEN for authentication:

https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

Grzegorz Krukowski
  • 18,081
  • 5
  • 50
  • 71