|
| 1 | +name: On pull request |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + tests: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + continue-on-error: false |
| 12 | + strategy: |
| 13 | + max-parallel: 3 |
| 14 | + matrix: |
| 15 | + php: |
| 16 | + - 7.2 |
| 17 | + - 7.3 |
| 18 | + - 7.4 |
| 19 | + - 8.0 |
| 20 | + - 8.1 |
| 21 | + composer: |
| 22 | + - 2 |
| 23 | + name: Test - php:${{ matrix.php }}; composer:${{ matrix.composer }} |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@master |
| 27 | + - name: Install PHP |
| 28 | + uses: shivammathur/setup-php@master |
| 29 | + with: |
| 30 | + php-version: ${{ matrix.php }} |
| 31 | + extensions: curl, gd, pdo_mysql, json, mbstring, pcre, session |
| 32 | + ini-values: post_max_size=256M |
| 33 | + coverage: none |
| 34 | + tools: composer:v${{ matrix.composer }} |
| 35 | + - name: Composer validate |
| 36 | + run: composer validate --strict --no-check-lock |
| 37 | + - name: Install Composer dependencies (with dev) |
| 38 | + run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader |
| 39 | + - name: Install Composer dependencies (without dev) |
| 40 | + run: composer install --no-progress --no-dev --no-suggest --prefer-dist --optimize-autoloader |
| 41 | + |
| 42 | + dependabot: |
| 43 | + needs: tests |
| 44 | + permissions: |
| 45 | + pull-requests: write |
| 46 | + contents: write |
| 47 | + runs-on: ubuntu-latest |
| 48 | + # Checking the actor will prevent your Action run failing on non-Dependabot |
| 49 | + # PRs but also ensures that it only does work for Dependabot PRs. |
| 50 | + if: ${{ github.actor == 'dependabot[bot]' }} |
| 51 | + steps: |
| 52 | + # This first step will fail if there's no metadata and so the approval |
| 53 | + # will not occur. |
| 54 | + - name: Dependabot metadata |
| 55 | + id: dependabot-metadata |
| 56 | + uses: dependabot/fetch-metadata@v1.3.3 |
| 57 | + with: |
| 58 | + github-token: "${{ secrets.GITHUB_TOKEN }}" |
| 59 | + # Here the PR gets approved. |
| 60 | + - name: Approve a PR |
| 61 | + run: gh pr review --approve "$PR_URL" |
| 62 | + env: |
| 63 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 64 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + # Finally, this sets the PR to allow auto-merging for patch and minor |
| 66 | + # updates if all checks pass |
| 67 | + - name: Enable auto-merge for Dependabot PRs |
| 68 | + # if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }} |
| 69 | + run: gh pr merge --auto --squash "$PR_URL" |
| 70 | + env: |
| 71 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 72 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments