From 1805b074ce5d9d978476fa4f9b24a913884e5adf Mon Sep 17 00:00:00 2001 From: Eser DENIZ Date: Fri, 21 Feb 2025 14:36:00 +0100 Subject: [PATCH 1/3] refactor: Check instead of commit php linting --- .../{fix-php-code-style-issues.yml => linting.yml} | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) rename .github/workflows/{fix-php-code-style-issues.yml => linting.yml} (63%) diff --git a/.github/workflows/fix-php-code-style-issues.yml b/.github/workflows/linting.yml similarity index 63% rename from .github/workflows/fix-php-code-style-issues.yml rename to .github/workflows/linting.yml index 0edbd389..eb484ef6 100644 --- a/.github/workflows/fix-php-code-style-issues.yml +++ b/.github/workflows/linting.yml @@ -1,13 +1,10 @@ -name: Fix PHP code style issues +name: Check PHP code style issues on: push: paths: - '**.php' -permissions: - contents: write - jobs: php-code-styling: runs-on: ubuntu-latest @@ -20,8 +17,6 @@ jobs: - name: Fix PHP code style issues uses: aglipanci/laravel-pint-action@2.5 - - - name: Commit changes - uses: stefanzweifel/git-auto-commit-action@v5 with: - commit_message: Fix styling + verboseMode: true + testMode: true From e1b69ea4d634c7c33cbe0099d7149b7673d9fe3a Mon Sep 17 00:00:00 2001 From: Eser DENIZ Date: Fri, 21 Feb 2025 14:39:09 +0100 Subject: [PATCH 2/3] fix: also on pull-requests --- .github/workflows/linting.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index eb484ef6..4a1bf1d6 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -4,6 +4,9 @@ on: push: paths: - '**.php' + pull_request: + paths: + - '**.php' jobs: php-code-styling: From 165076691c6167705bcae8d8bf348b3f88c73b04 Mon Sep 17 00:00:00 2001 From: Eser DENIZ Date: Fri, 21 Feb 2025 21:07:07 +0100 Subject: [PATCH 3/3] fix: check on main, fix on pull-request --- .../workflows/fix-php-code-style-issues.yml | 43 +++++++++++++++++++ .github/workflows/linting.yml | 25 ----------- 2 files changed, 43 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/fix-php-code-style-issues.yml delete mode 100644 .github/workflows/linting.yml diff --git a/.github/workflows/fix-php-code-style-issues.yml b/.github/workflows/fix-php-code-style-issues.yml new file mode 100644 index 00000000..eb79b6e0 --- /dev/null +++ b/.github/workflows/fix-php-code-style-issues.yml @@ -0,0 +1,43 @@ +# Check and fix PHP code style issues +# Pull request: automatically fix PHP code style issues +# Main branch: only check PHP code style issues since we don't have write permission +name: Check and fix PHP code style issues + +on: + push: + paths: + - '**.php' + pull_request: + paths: + - '**.php' + +permissions: + contents: write + +jobs: + php-code-styling: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + - name: Check PHP code style issues + if: github.event_name == 'push' + uses: aglipanci/laravel-pint-action@2.5 + with: + verboseMode: true + testMode: true + + - name: Fix PHP code style issues + if: github.event_name == 'pull_request' + uses: aglipanci/laravel-pint-action@2.5 + + - name: Commit changes + if: github.event_name == 'pull_request' + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Fix styling + diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml deleted file mode 100644 index 4a1bf1d6..00000000 --- a/.github/workflows/linting.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Check PHP code style issues - -on: - push: - paths: - - '**.php' - pull_request: - paths: - - '**.php' - -jobs: - php-code-styling: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref }} - - - name: Fix PHP code style issues - uses: aglipanci/laravel-pint-action@2.5 - with: - verboseMode: true - testMode: true