Skip to content

Commit

Permalink
Update php.yml
Browse files Browse the repository at this point in the history
Signed-off-by: ArchBlood <[email protected]>
  • Loading branch information
ArchBlood authored Oct 25, 2024
1 parent cbb6ebe commit 14d6351
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PHP Composer
name: PHP Composer
on:
push:
branches: ["main", "develop"]
Expand All @@ -16,12 +16,12 @@ jobs:
ref: ${{ github.head_ref }}
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup PHP
uses: shivammathur/[email protected]
with:
php-version: '8.2'

- name: Debug event info
run: |
echo "Event name: ${{ github.event_name }}"
Expand All @@ -32,8 +32,8 @@ jobs:
id: check-changes
if: github.event_name == 'pull_request'
run: |
git fetch origin ${{ github.base_ref }}
git diff --name-only origin/${{ github.base_ref }} HEAD | grep -q "composer.json" && echo "changed=true" >> $GITHUB_OUTPUT || echo "changed=false" >> $GITHUB_OUTPUT
git fetch origin ${{ github.event.pull_request.base.ref }}
git --no-pager diff --name-only origin/${{ github.event.pull_request.base.ref }} HEAD | grep -q "composer.json" && echo "changed=true" >> $GITHUB_OUTPUT || echo "changed=false" >> $GITHUB_OUTPUT
- name: Cache Composer packages
id: composer-cache
Expand All @@ -44,20 +44,17 @@ jobs:
restore-keys: |
${{ runner.os }}-php-
# Always update in PR if composer.json changed
- name: Update dependencies in PR
if: github.event_name == 'pull_request' && steps.check-changes.outputs.changed == 'true'
run: |
echo "Running composer update because composer.json changed"
composer update --prefer-dist --no-progress
# Regular install for non-PR or when composer.json hasn't changed
- name: Install dependencies
if: github.event_name != 'pull_request' || steps.check-changes.outputs.changed != 'true'
run: |
composer install --prefer-dist --no-progress
# Commit changes if we're in a PR and composer.json was changed
- name: Commit and push updated lock file
if: github.event_name == 'pull_request' && steps.check-changes.outputs.changed == 'true'
run: |
Expand Down

0 comments on commit 14d6351

Please sign in to comment.