1

composer-runtime-api ^2.0.0即使actions/checkout@v2使用使用composerv2的 Github 操作部署由于不匹配而失败

laravel.yml:

name: Deploy to staging

on:
  push:
    branches: [ staging ]

jobs:
  vapor:
    name: Check out, build and deploy using Vapor
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: ubient/laravel-vapor-action@master
        env:
          VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
        with:
          args: "deploy staging"

作曲家.json:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.4",
        "aws/aws-sdk-php": "3.166.2",
        "barryvdh/laravel-dompdf": "^0.8.7",
        "bensampo/laravel-enum": "^3.2.0",
        "doctrine/dbal": "^2.10",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "laravel/framework": "^8.0",
        "laravel/helpers": "^1.3",
        "laravel/sanctum": "^2.4",
        "laravel/tinker": "^2.5",
        "laravel/vapor-cli": "^1.12",
        "laravel/vapor-core": "^2.8",
        "laravel/vapor-ui": "^1.0",
        "owen-it/laravel-auditing": "^10.0",
        "pusher/pusher-php-server": "^4.1",
        "sentry/sentry-laravel": "^2.3",
        "spatie/laravel-permission": "^3.16",
        "spatie/laravel-tags": "^2.7"
    },
    "require-dev": {
        "barryvdh/laravel-ide-helper": "^2.8",
        "beyondcode/laravel-dump-server": "^1.4",
        "facade/ignition": "^2.5",
        "fzaninotto/faker": "^1.9.1",
        "laravel/horizon": "^5.6",
        "laravel/sail": "^1.1",
        "laravel/telescope": "^4.4.0",
        "mockery/mockery": "^1.4.2",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3.3"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": [
                "barryvdh/laravel-ide-helper",
                "laravel/telescope"
            ]
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        },
        "classmap": [
        ],
        "files": [
            "bootstrap/helpers.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "@php artisan ide-helper:generate",
            "@php artisan ide-helper:meta"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

错误:

Building project...
==> Validating Manifest File
==> Copying Application Files
==> Harmonizing Configuration Files
==> Setting Build Environment
==> Executing Build Commands
==> Running Command: composer install --no-dev
Loading composer repositories with package information
Installing dependencies from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for jean85/pretty-package-versions 2.0.3 -> satisfiable by jean85/pretty-package-versions[2.0.3].
    - jean85/pretty-package-versions 2.0.3 requires composer-runtime-api ^2.0.0 -> no matching package found.
  Problem 2
    - jean85/pretty-package-versions 2.0.3 requires composer-runtime-api ^2.0.0 -> no matching package found.
    - sentry/sentry 3.2.0 requires jean85/pretty-package-versions ^1.5|^2.0.1 -> satisfiable by jean85/pretty-package-versions[2.0.3].
    - Installation request for sentry/sentry 3.2.0 -> satisfiable by sentry/sentry[3.2.0].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
 - It's a private package and you forgot to add a custom repository to find it

部署命令是'composer install --no-dev'. 起初,我actions/checkout@v1在遇到此错误时正在使用,然后actions/checkout@v2当我了解composer v2on checkout@v2vs v1on时,我转移到了checkout@v1,但问题仍然存在......欢迎任何关于为什么会发生这种情况的提示。

编辑:我能够从我的本地设备运行部署,没有任何问题(一旦我转移到作曲家 v2)。

4

1 回答 1

0

由于@bk2204 帮助我认识到我的错误假设,即 checkout@v2 将作曲家设置为 v2,我能够通过更改部署说明来解决我的问题,laravel.yml如下所示:

name: Deploy to staging

on:
  push:
    branches: [ staging ]

jobs:
  vapor:
    name: Check out, build and deploy using Vapor
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Setup PHP (w/ extensions) & Composer
      uses: shivammathur/setup-php@v2
      with:
        php-version: 7.4
        tools: pecl
        extensions: bcmath, ctype, fileinfo, json, mbstring, openssl, pdo, tokenizer, xml, zip, pcntl
        coverage: none

    - name: Obtain Composer cache directory
      id: composer-cache
      run: echo "::set-output name=dir::$(composer config cache-files-dir)"

    - name: Cache Composer dependencies
      uses: actions/cache@v1
      with:
        path: ${{ steps.composer-cache.outputs.dir }}
        # Use composer.json for key, if composer.lock is not committed.
        # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
        key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
        restore-keys: ${{ runner.os }}-composer-

    - name: Install Vapor CLI Globally
      run: composer global require laravel/vapor-cli

    - name: Install Composer dependencies
      run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader --no-dev

    - name: Deploy using Laravel Vapor
      env:
        VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
      run: /home/runner/.composer/vendor/bin/vapor deploy staging

于 2021-03-28T22:22:17.343 回答