Open1

pre-commitをGitHub Actionsで実行する際に、プルリクエストに含まれるファイルだけを対象にする

Nakano as a ServiceNakano as a Service
name: pre-commit check
on:
  workflow_dispatch:
  pull_request:
    types: [opened, synchronize, reopened]
    branches:
      - develop
      - feature/*

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-python@v3
      - uses: pre-commit/action@v3.0.0
        with:
          extra_args: --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}