Update code-style.yml #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: | ||
|
Check failure on line 1 in .github/workflows/code-style.yml
|
||
| workflow_call: | ||
| permissions: write-all | ||
| jobs: | ||
| php: | ||
| name: PHP | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - uses: shivammathur/setup-php@v2 | ||
| - name: Can fix detect | ||
| id: can_fix | ||
| shell: bash | ||
| run: | | ||
| CAN_FIX=${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | ||
| echo "CAN_FIX=${CAN_FIX}" >> "$GITHUB_ENV" | ||
| - name: Setup Composer | ||
| run: | | ||
| composer global config --no-plugins allow-plugins.laravel/pint true | ||
| composer global config --no-plugins allow-plugins.ergebnis/composer-normalize true | ||
| composer config --no-plugins allow-plugins.laravel/pint true | ||
| composer config --no-plugins allow-plugins.ergebnis/composer-normalize true | ||
| - name: Install Composer dependencies | ||
| run: composer global require dragon-code/codestyler | ||
| - name: Publish config files | ||
| run: codestyle pint 8.2 | ||
| - name: Normalize composer.json | ||
| if: $CAN_FIX == true | ||
| run: composer normalize | ||
| - name: Code-style | ||
| run: | | ||
| if [ $CAN_FIX == true ]; then | ||
| pint --parallel | ||
| else | ||
| pint --parallel --test | ||
| fi | ||
| node: | ||
| name: Node | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - uses: shivammathur/setup-php@v2 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 'latest' | ||
| - name: Can fix detect | ||
| id: can_fix | ||
| shell: bash | ||
| run: | | ||
| CAN_FIX=${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | ||
| echo "CAN_FIX=${CAN_FIX}" >> "$GITHUB_ENV" | ||
| - name: Detect package.json | ||
| id: has_pkg | ||
| shell: bash | ||
| run: | | ||
| if [ -f package.json ]; then | ||
| echo "HAS_PACKAGE_JSON=1" >> "$GITHUB_ENV" | ||
| else | ||
| echo "HAS_PACKAGE_JSON=0" >> "$GITHUB_ENV" | ||
| fi | ||
| - name: Install Composer dependencies | ||
| run: composer global require dragon-code/codestyler | ||
| - name: Install Node dependencies | ||
| run: npm i -D @biomejs/biome | ||
| - name: Publish config files | ||
| run: codestyle npm | ||
| - name: Code-style | ||
| run: | | ||
| if [ $CAN_FIX == true ]; then | ||
| npx @biomejs/biome lint --write | ||
| npx @biomejs/biome format --write | ||
| else | ||
| npx @biomejs/biome lint | ||
| npx @biomejs/biome format | ||
| fi | ||
| - name: Remove node_modules | ||
| if: $CAN_FIX == true | ||
| run: rm -rf node_modules | ||
| - name: Remove package.json | ||
| if: env.HAS_PACKAGE_JSON == '0' | ||
| run: | | ||
| rm package.json | ||
| rm package-lock.json | ||
| pr: | ||
| needs: | ||
| - php | ||
| - node | ||
| name: Create a PR | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - name: Create a Pull Request | ||
| uses: peter-evans/create-pull-request@v7 | ||
| with: | ||
| branch: code-style | ||
| branch-suffix: random | ||
| delete-branch: true | ||
| title: "🦋 The code style has been fixed" | ||
| commit-message: 🦋 The code style has been fixed | ||
| body: The code style has been fixed | ||
| labels: code-style | ||