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 1e2e1b6 commit 37dbad2
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ permissions:
jobs:
build:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -23,13 +22,10 @@ jobs:
with:
php-version: '8.2'

- name: Check for composer.json changes
id: check-composer
run: |
git diff --name-only origin/${{ github.base_ref }} HEAD | grep -q "composer.json" && echo "changed=true" >> $GITHUB_OUTPUT || echo "changed=false" >> $GITHUB_OUTPUT
- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
if: steps.check-composer.outputs.changed == 'true'
id: composer-cache
uses: actions/cache@v3
with:
Expand All @@ -38,13 +34,28 @@ jobs:
restore-keys: |
${{ runner.os }}-php-
- name: Update dependencies if composer.json changed
if: steps.check-composer.outputs.changed == 'true'
- name: Check for composer.json changes
id: check-composer
if: github.event_name == 'pull_request'
run: |
git diff --name-only origin/${{ github.base_ref }} HEAD | grep -q "composer.json" && echo "changed=true" >> $GITHUB_OUTPUT || echo "changed=false" >> $GITHUB_OUTPUT
- name: Install dependencies (Push to main/develop)
if: github.event_name == 'push'
run: |
if [ -f composer.lock ]; then
composer install --prefer-dist --no-progress
else
composer update --prefer-dist --no-progress
fi
- name: Update dependencies if composer.json changed (PR)
if: github.event_name == 'pull_request' && steps.check-composer.outputs.changed == 'true'
run: |
composer update --prefer-dist --no-progress
- name: Commit and push if composer.lock changed
if: steps.check-composer.outputs.changed == 'true'
- name: Commit and push if composer.lock changed (PR)
if: github.event_name == 'pull_request' && steps.check-composer.outputs.changed == 'true'
run: |
if git diff --exit-code composer.lock; then
echo "No changes to composer.lock needed"
Expand Down

0 comments on commit 37dbad2

Please sign in to comment.