-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomposer-compatibility-check.yml
85 lines (73 loc) · 2.84 KB
/
composer-compatibility-check.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
78
79
80
81
82
83
84
85
name: Composer Compatibility Check
on:
workflow_dispatch: # Manual trigger
push:
paths:
- 'composer.json'
- 'composer.lock'
pull_request:
paths:
- 'composer.json'
- 'composer.lock'
jobs:
check-compatibility:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.4', '8.0', '8.1', '8.2']
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer:v2
coverage: none
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Validate composer.json
run: composer validate --strict
- name: Check compatibility and update if needed
run: |
# Try to install from lock first
if ! composer install --no-interaction --prefer-dist; then
echo "Installation from lock failed, updating packages..."
# Remove lock file
rm -f composer.lock
# Update dependencies
composer update --no-interaction --prefer-dist
fi
- name: Create Pull Request if changes detected
if: failure() && github.event_name != 'pull_request'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "🔄 Update composer dependencies for PHP ${{ matrix.php-versions }}"
title: "Composer Dependencies Update for PHP ${{ matrix.php-versions }}"
body: |
This PR updates composer dependencies to be compatible with PHP ${{ matrix.php-versions }}.
Changes were automatically generated due to compatibility issues detected in the workflow.
Please review the changes and merge if appropriate.
branch: fix/composer-compatibility-php-${{ matrix.php-versions }}
delete-branch: true
base: main
- name: Comment on failed installation
if: failure() && github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.name,
body: '❌ Dependency installation failed for PHP ${{ matrix.php-versions }}. Please check the workflow logs for details.'
})