php - PHPUnit 的 GitHub 操作失败

标签 php laravel github phpunit github-actions

我正在使用 GitHub Actions 为创建的每个拉取请求运行 PHP CS Fixer 和 PHPUnit。我为 PHPUnit 实现了这个 GitHub Action,我的 YML 文件如下。

name: PHPUnit Tests

on: [push]

jobs:
  build-test:
    name: PHPUnit Tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: php-actions/composer@v5
        with:
          php_extensions: mailparse pdo_mysql
          dev: no
          args: --profile --ignore-platform-reqs

      - name: PHPUnit Tests
        uses: php-actions/phpunit@v3
        with:
          php_version: 8.1

我在 PHPUnit Action 中遇到以下错误。

994393dc58e7: Layer already exists
1e74372f6dff: Pushed
php-latest-mailparse-pdo_mysql-build2: digest: sha256:17078db8c8e36a72ce937d8b5f98eb0c0b814b91a2c20e14788039763b722300 size: 2831
Docker tag: docker.pkg.github.com/synega/connect/php-actions_composer_connect:php-latest-mailparse-pdo_mysql-build2
No private keys supplied
Command: composer install --no-dev --no-progress --no-interaction --profile --ignore-platform-reqs
Error: Process completed with exit code 1.

我如何/在哪里可以获得 mailparse 的私钥?任何帮助将不胜感激。

最佳答案

不是 mailparse 需要私钥,而是整个项目 - 私有(private)存储库需要使用 SSH 身份验证 - 请参阅 composer-php-actions manual :

To install from a private repository, SSH authentication must be used. Generate an SSH key pair for this purpose and add it to your private repository's configuration, preferable with only read-only privileges. On Github for instance, this can be done by using deploy keys.

Add the key pair to your project using Github Secrets, and pass them into the php-actions/composer action by using the ssh_key and ssh_key_pub inputs. If your private repository is stored on another server than github.com, you also need to pass the domain via ssh_domain.

Example yaml, showing how to pass secrets:

jobs:
  build:

    ...

    - name: Install dependencies
      uses: php-actions/composer@v6
      with:
        ssh_key: ${{ secrets.ssh_key }}
        ssh_key_pub: ${{ secrets.ssh_key_pub }}

There is an example repository available for reference at https://github.com/php-actions/example-composer that uses a private dependency. Check it out for a live working project.

关于 Github Secrets 的文档介绍了如何为 Github 创建它们。

关于php - PHPUnit 的 GitHub 操作失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74254311/

相关文章:

php - 使用 PHP 在多个数组中查找公共(public)值

php - 如何识别两个相同的 nohup 命令?

Laravel nova 操作 - 获取字段上的当前模型实例()

java - secure-connect-DBNAME.zip 上传到存储库是否安全?

git - 使用 NPM 打包 fork Git 存储库的 BUILT 版本的正确方法是什么?

php - 我如何制作幻灯片,从数据库中获取信息(图像、标题、内容)?

php - 如何从循环的 html 表单中获取变量?

open-source - 白标协作开源开发(例如 github/sourceforge/google-code)?

php - 分离从 mysqli_fetch_array 返回的两个数组

php - 复制整个模型的数据库并插入到同一个表中并更改列