/run_prettier_action

Primary LanguageJavaScriptMIT LicenseMIT

run_prettier_action

Usage

on:
  issue_comment:
    types: [created]

jobs:
  prettier:
    runs-on: ubuntu-latest
    name: Run Prettier
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          # see https://github.com/stefanzweifel/git-auto-commit-action#commits-of-this-action-do-not-trigger-new-workflow-runs
          token: ${{ secrets.PRIVATE_ACCESS_TOKEN }}

      - uses: actions/setup-node@v2
        with:
          node-version: "16"
          cache: 'npm'

      - run: npm ci

      - name: run prettier command
        uses: ykpythemind/run_prettier_action@v1
        with:
          prettier_command: ./node_modules/.bin/prettier --write
          GITHUB_TOKEN: ${{ secrets.PRIVATE_ACCESS_TOKEN }}

      - uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Apply prettier changes
          skip_fetch: true

image

About (Japanese)

インストールすると、PRコメントで /prettier を入力することで自動でprettierをかけ、commitを積んでくれるactionが起動します。 pre commit hookが苦手な方、任意のタイミングでprettierかけたい方にオススメです

option

prerequisite

Your repository must contain prettier package on package.json

build actions

npm run ncc

test

Integration

Go to https://github.com/ykpythemind/run_prettier_action/actions/workflows/integration.yml and dispatch workflow.