-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (74 loc) · 2.47 KB
/
on-pull-request.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: On pull request
on:
pull_request:
branches:
- main
jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 2
matrix:
php:
- 7.3
- 7.4
- 8.0
- 8.1
os:
- ubuntu-latest
- windows-latest
- macOS-latest
name: PHP ${{ matrix.php }}; ${{ matrix.os }}
steps:
- name: Setup PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php }}
extensions: curl, json, mbstring, pcre
ini-values: memory_limit=512M
tools: composer:v2
- name: Check PHP Version
run: php -v
- name: Checkout
uses: actions/checkout@v4
- name: Composer install without dev
run: composer install --no-progress --no-dev --prefer-dist --optimize-autoloader
- name: Composer install with dev
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: PHPUnit (not windows)
run: ./vendor/bin/phpunit tests/
if: matrix.os != 'windows-latest'
- name: PHPUnit (windows)
run: .\vendor\bin\phpunit tests/
if: matrix.os == 'windows-latest'
dependabot:
needs: tests
permissions:
pull-requests: write
contents: write
runs-on: ubuntu-latest
# Checking the actor will prevent your Action run failing on non-Dependabot
# PRs but also ensures that it only does work for Dependabot PRs.
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
# This first step will fail if there's no metadata and so the approval
# will not occur.
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v2.1.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
# Here the PR gets approved.
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Finally, this sets the PR to allow auto-merging for patch and minor
# updates if all checks pass
- name: Enable auto-merge for Dependabot PRs
# if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}