【问题标题】:How do you set the PHP version with this GitHub Actions workflow?您如何使用此 GitHub Actions 工作流程设置 PHP 版本?
【发布时间】:2021-03-13 22:41:47
【问题描述】:

我使用 GitHub Actions 工作流已经有一段时间了:

name: Laravel

on: [push]

jobs:
  laravel-tests:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Copy .env
      run: php -r "file_exists('.env') || copy('.env.example', '.env');"
    - name: Install Dependencies
      run: |
        rm -rf vendor
        composer install
    - name: Generate key
      run: php artisan key:generate
    - name: Link Storage
      run: php artisan storage:link
    - name: Create Database
      run: |
        mkdir -p database
        touch database/database.sqlite
    - name: Execute tests (Unit and Feature tests) via PHPUnit
      env:
        DB_CONNECTION: sqlite
        DB_DATABASE: database/database.sqlite
      run: vendor/bin/phpunit --stop-on-failure

它一直工作到 8.0 出来,然后 composer 爆发了一堆错误,我定期更新的这个和那个包与 8.0 不兼容。

任何人,我现在需要将此设置为使用 7.4。

我明白了:

with:
  php-version: '7.4'

我知道我可以使用矩阵,但是我在哪里调用整个“使用这个 php 版本”在这个脚本中以使测试针对 7.4 运行?

【问题讨论】:

标签: laravel github-actions


【解决方案1】:

使用setup-php 操作:

name: Laravel

on: [push]

jobs:
  laravel-tests:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1    
    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: 7.4
    - name: Copy .env
      run: php -r "file_exists('.env') || copy('.env.example', '.env');"
    [...]

【讨论】:

    猜你喜欢
    • 2020-04-02
    • 2022-01-10
    • 2022-12-13
    • 2022-08-13
    • 2022-11-02
    • 1970-01-01
    • 2022-11-02
    • 2020-01-18
    • 2020-04-03
    相关资源
    最近更新 更多