Skip to main content

在 CI 上运行 Prettier

GitHub Actions

要从 GitHub Actions 应用 Prettier 的自动修复功能,请执行以下操作:

¥To apply autofix for Prettier from GitHub Actions, do the following:

  1. 安装 autofix.ci GitHub 应用。

    ¥Install the autofix.ci GitHub App.

  2. 确保你的仓​​库中安装了 Prettier 的固定版本。

    ¥Make sure you have a pinned version of Prettier installed in your repository.

  3. 创建包含以下内容的 .github/workflows/prettier.yml

    ¥Create .github/workflows/prettier.yml with following content:

    .github/workflows/prettier.yml
    name: autofix.ci
    on:
    pull_request:
    push:
    permissions: {}
    jobs:
    prettier:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-node@v4
    - run: |
    yarn
    yarn prettier . --write
    - uses: autofix-ci/action@v1
    with:
    commit-message: "Apply Prettier format"

更多信息请访问 autofix.ci 网站。

¥For more information see autofix.ci website.