Browse Source

Merge pull request #1572 from Anankke/test-only-run-lint-on-php-file

test: only run lint on php file
M1Screw 3 years ago
parent
commit
a22a2a6579
1 changed files with 22 additions and 0 deletions
  1. 22 0
      .github/workflows/lint.yml

+ 22 - 0
.github/workflows/lint.yml

@@ -5,8 +5,30 @@ on:
     types: [opened, reopened, synchronize]
     types: [opened, reopened, synchronize]
 
 
 jobs:
 jobs:
+  check_php_files:
+    runs-on: ubuntu-latest
+    outputs:
+      php_changed: ${{ steps.check_file_changed.outputs.php_file_changed }}
+    steps:
+    - uses: actions/checkout@v2
+      with:
+        fetch-depth: 2
+    - shell: pwsh
+      id: check_php_file_changed
+      run: |
+        # Diff HEAD with the previous commit
+        $diff = git diff --name-only HEAD^ HEAD
+
+        # Check if a file under docs/ or with the .md extension has changed (added, modified, deleted)
+        $SourceDiff = $diff | Where-Object { $_ -match '.php$' }
+        $HasDiff = $SourceDiff.Length -gt 0
+
+        # Set the output named "docs_changed"
+        Write-Host "::set-output name=php_file_changed::$HasDiff"
   lint:
   lint:
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
+    needs: [ check_php_files ]
+    if: needs.check_php_files.outputs.php_file_changed == 'True'
     steps:
     steps:
       - uses: actions/checkout@v2
       - uses: actions/checkout@v2
         with:
         with: