From 1932b706a55e46f68a1e32072e8b4ba59b7871bc Mon Sep 17 00:00:00 2001 From: mauricius Date: Fri, 10 Jul 2020 11:28:27 +0200 Subject: [PATCH] Add GH action for php-cs --- .github/workflows/format.yml | 22 ++++++++++++++++++++++ .php_cs | 19 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 .github/workflows/format.yml create mode 100644 .php_cs diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 00000000..026cfbfa --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,22 @@ +name: Format [PHP] + +on: + pull_request: + paths: + - '**.php' + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - name: Run php-cs-fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php_cs + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Apply php-cs-fixer changes \ No newline at end of file diff --git a/.php_cs b/.php_cs new file mode 100644 index 00000000..a6b39063 --- /dev/null +++ b/.php_cs @@ -0,0 +1,19 @@ +notPath('node_modules') + ->notPath('vendor') + ->notPath('public') + ->notPath('resources') + ->in(__DIR__) + ->name('*.php') + ->notName('*.blade.php'); + +return PhpCsFixer\Config::create() + ->setRules([ + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => ['sortAlgorithm' => 'alpha'], + 'no_unused_imports' => true, + ]) + ->setFinder($finder);