Github 操作部署失败,因为不匹配 composer-runtime-api ^2.0.0 但使用了 actions/checkout@v2
Posted
技术标签:
【中文标题】Github 操作部署失败,因为不匹配 composer-runtime-api ^2.0.0 但使用了 actions/checkout@v2【英文标题】:Github action deployment fails because of not matching composer-runtime-api ^2.0.0 but actions/checkout@v2 is used 【发布时间】:2021-06-25 00:28:05 【问题描述】:Github 操作部署失败,因为不匹配 composer-runtime-api ^2.0.0
,即使使用了使用 composer
v2 的 actions/checkout@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:
- uses: actions/checkout@v2
- uses: ubient/laravel-vapor-action@master
env:
VAPOR_API_TOKEN: $ secrets.VAPOR_API_TOKEN
with:
args: "deploy staging"
composer.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
,然后在我了解到composer v2
在checkout@v2
上与v1
在checkout@v1
上时,我转移到actions/checkout@v2
,但问题仍然存在......任何欢迎提供有关为什么会发生这种情况的提示。
编辑:我可以从本地设备运行部署,没有任何问题(一旦我转移到 composer v2)。
【问题讨论】:
actions/checkout@v2
只影响 Git 检出;它不会影响 Composer 或任何其他软件。如果您需要特定版本的 Composer,请查找提供该版本的操作。
【参考方案1】:
@bk2204 帮助我认识到我的错误假设,即 checkout@v2 将 composer 设置为 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
【讨论】:
以上是关于Github 操作部署失败,因为不匹配 composer-runtime-api ^2.0.0 但使用了 actions/checkout@v2的主要内容,如果未能解决你的问题,请参考以下文章
Azure 部署中心的 CI/CD 失败,因为存储库名称必须小写
github操作中的Maven部署不断失败,但在本地运行良好