From fdce1714b6e7f371866fa38d3e78d8477b355ed8 Mon Sep 17 00:00:00 2001 From: cnk Date: Thu, 24 Oct 2024 11:34:52 +0800 Subject: [PATCH] chore(CI): fix CI --- .github/workflows/autocorrect-check.yml | 26 +++++++---- .github/workflows/prettier-check.yml | 61 ------------------------- 2 files changed, 18 insertions(+), 69 deletions(-) delete mode 100644 .github/workflows/prettier-check.yml diff --git a/.github/workflows/autocorrect-check.yml b/.github/workflows/autocorrect-check.yml index 8602b86..e319172 100644 --- a/.github/workflows/autocorrect-check.yml +++ b/.github/workflows/autocorrect-check.yml @@ -12,23 +12,33 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Install and run AutoCorrect - run: | + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v3 + + - name: Install and run format + run: | + # 安装 autocorrect curl -sSL https://raw.githubusercontent.com/huacnlee/autocorrect/main/install | sh + # 修复文件格式 autocorrect --fix - + # 安装并运行 prettier + npm install -g prettier + prettier --write . + # 检查是否有文件更改 - name: Check for changes run: git diff --exit-code || git status - + # 如果有更改,则配置 Git 提交用户名和邮箱,并提交更改 - name: Commit changes - if: success() || failure() # 确保失败时继续 + if: success() run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" git add . - git commit -m "AutoCorrect: Fix Markdown formatting" + git commit -m "fix(typo): Fix Markdown formatting" git push - continue-on-error: true # 即使没有更改也不影响其他步骤 + continue-on-error: true # 即使没有更改也不影响其他步骤 diff --git a/.github/workflows/prettier-check.yml b/.github/workflows/prettier-check.yml deleted file mode 100644 index 991fd9d..0000000 --- a/.github/workflows/prettier-check.yml +++ /dev/null @@ -1,61 +0,0 @@ -# .github/workflows/prettier-check.yml - -name: Prettier Markdown Check - -on: - push: - branches: ["**"] - paths: - - "**/*.md" - pull_request: - branches: ["**"] - paths: - - "**/*.md" - -jobs: - prettier: - name: Check Markdown Formatting with Prettier - runs-on: ubuntu-latest - - steps: - # Step 1: Checkout the repository - - name: Checkout Repository - uses: actions/checkout@v3 - - # Step 2: Set up Node.js environment - # Prettier requires Node.js to run - - name: Set up Node.js - uses: actions/setup-node@v3 - # with: - # node-version: "20" # Optional: Remove this line to eliminate deprecation warning - - # Step 3: Install Prettier Globally - - name: Install Prettier - run: npm install -g prettier - - # Step 4: Run Prettier Check on Markdown Files - - name: Run Prettier Check - run: | - prettier --check "**/*.md" - - # Optional Step 5: Display Formatted Files - - name: Show Unformatted Files - if: failure() - run: | - echo "The following Markdown files are not properly formatted:" - prettier --list-different "**/*.md" - - # Step 6: try auto fix - - name: Auto Fix - if: failure() - run: | - prettier --write "**/*.md" - - - name: Commit and Push - if: failure() - run: | - git config --global user.email "action@github.com" - git config --global user.name "GitHub Action" - git add . - git commit -m "Fix markdown formatting" - git push