0

我正在尝试使用 Github 操作部署应用程序,但由于我的应用程序中有一个私有 pod,我遇到了很多问题。我查看了如何解决这个问题的各种建议,但我找到的答案都没有帮助我部署应用程序。这是我的脚本的样子:

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"

还有我的 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

我收到一条错误消息:致命:无法从远程存储库中读取。请确保您拥有正确的访问权限。

我还尝试了一种通过 pod repo add 命令手动添加 repo 的方法,但仍然出现错误。我的理解是脚本中的“凭据设置”行应该足以验证我的 github 帐户并允许我安装私有 repo,但它似乎不起作用。

4

1 回答 1

0

要对私有存储库进行身份验证,您必须使用 SSH 密钥而不是https-https仅使用钥匙串密码并在不存在时提示输入用户/密码 - 它不适用于 CI。

切换到: git@github.com:organization/privatepod.git

此外,如果您启用了 2FA(我希望您这样做) - 您需要使用 PERSONAL_TOKEN 进行身份验证:

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

于 2022-02-27T11:00:49.733 回答