Skip to content

fix: prettier php workflow #201

fix: prettier php workflow

fix: prettier php workflow #201

Workflow file for this run

name: Format Prettier
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
cancel-runs:
if: github.event_name == 'pull_request' && github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
prettier:
if: ${{ github.ref != 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Set up Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
- name: Actions checkout
uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Node.js dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Dependencies
run: npm install prettier @prettier/plugin-php stylelint-prettier
- name: Run Prettier and Stylelint
run: |
npx prettier --write "**/*.{php,js}" --plugin=@prettier/plugin-php --ignore-unknown
npx stylelint "**/*.css" --fix
shell: bash
- name: Commit Changes
uses: EndBug/add-and-commit@v9
with:
author_name: GitHub Actions
author_email: 41898282+github-actions[bot]@users.noreply.github.com
message: 'PHP code format - (prettier)'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}