Explorar el Código

【维护】添加 AutoCorrect 自动格式检查功能

在 GitHub Actions 工作流中集成 huacnlee/autocorrect-action,
用于 PR 代码的自动纠错和格式检查,提升格式质量。
PJ568 hace 10 meses
padre
commit
81661f798e
Se han modificado 3 ficheros con 73 adiciones y 75 borrados
  1. 15 18
      .github/workflows/check.yml
  2. 57 56
      .github/workflows/release.yml
  3. 1 1
      README.md

+ 15 - 18
.github/workflows/check.yml

@@ -1,27 +1,24 @@
 name: check
 
-on: [push, pull_request, merge_group, workflow_dispatch]
+on: [pull_request, merge_group, workflow_dispatch, workflow_call]
 
 jobs:
   check:
     runs-on: ubuntu-latest
     name: Check
     steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
 
-    - name: Checkout
-      uses: actions/checkout@v4
-      with:
-        fetch-depth: 0
-    
-    - name: Check version
-      id: version-check
-      run: |
-        chmod +x ./scripts/is-newer-version.bash
-        chmod +x ./scripts/get-version.bash
-        VERSION=$(./scripts/is-newer-version.bash)
-        echo "version=${VERSION}" >> $GITHUB_OUTPUT
-        if [ "$VERSION" != "0" ]; then
-          echo "New version detected: $VERSION"
-        else
-          echo "No new version to release"
-        fi
+      - name: AutoCorrect
+        uses: huacnlee/autocorrect-action@v2
+
+      - name: Report ReviewDog
+        if: failure()
+        uses: huacnlee/autocorrect-action@v2
+        env:
+          REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          reviewdog: true

+ 57 - 56
.github/workflows/release.yml

@@ -1,4 +1,4 @@
-name: release
+name: release and deploy
 
 on:
   workflow_dispatch:
@@ -7,72 +7,73 @@ on:
       - master
 
 jobs:
+  test:
+    uses: ./.github/workflows/check.yml
   release:
     runs-on: ubuntu-latest
     permissions: write-all
     name: Release
     steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
 
-    - name: Checkout
-      uses: actions/checkout@v4
-      with:
-        fetch-depth: 0
-    
-    - name: Check version
-      id: version-check
-      run: |
-        chmod +x ./scripts/is-newer-version.bash
-        chmod +x ./scripts/get-version.bash
-        VERSION=$(./scripts/is-newer-version.bash)
-        echo "version=${VERSION}" >> $GITHUB_OUTPUT
-        if [ "$VERSION" != "0" ]; then
-          echo "New version detected: $VERSION"
-        else
-          echo "No new version to release"
-        fi
+      - name: Check version
+        id: version-check
+        run: |
+          chmod +x ./scripts/is-newer-version.bash
+          chmod +x ./scripts/get-version.bash
+          VERSION=$(./scripts/is-newer-version.bash)
+          echo "version=${VERSION}" >> $GITHUB_OUTPUT
+          if [ "$VERSION" != "0" ]; then
+            echo "New version detected: $VERSION"
+          else
+            echo "No new version to release"
+          fi
 
-    - name: Push tag
-      if: steps.version-check.outputs.version != '0'
-      id: push-tag
-      run: |
-        tag="v${{ steps.version-check.outputs.version }}"
-        git config user.name "${GITHUB_ACTOR}"
-        git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
-        git tag -a "${tag}" -m "Release ${tag}"
-        git push origin "${tag}"
-        echo "tag_name=${tag}" >> $GITHUB_OUTPUT
+      - name: Push tag
+        if: steps.version-check.outputs.version != '0'
+        id: push-tag
+        run: |
+          tag="v${{ steps.version-check.outputs.version }}"
+          git config user.name "${GITHUB_ACTOR}"
+          git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
+          git tag -a "${tag}" -m "Release ${tag}"
+          git push origin "${tag}"
+          echo "tag_name=${tag}" >> $GITHUB_OUTPUT
 
-    - name: Checkout
-      if: steps.version-check.outputs.version != '0'
-      uses: actions/checkout@v4
+      - name: Checkout
+        if: steps.version-check.outputs.version != '0'
+        uses: actions/checkout@v4
 
-    - name: Create release
-      if: steps.version-check.outputs.version != '0'
-      uses: ncipollo/release-action@v1
-      with:
-        generateReleaseNotes: true
-        tag: "v${{ steps.version-check.outputs.version }}"
-        artifacts: "./README.md"
+      - name: Create release
+        if: steps.version-check.outputs.version != '0'
+        uses: ncipollo/release-action@v1
+        with:
+          generateReleaseNotes: true
+          tag: "v${{ steps.version-check.outputs.version }}"
+          artifacts: "./README.md"
 
-    - name: Drop markdown.html
-      uses: PJ-568/[email protected]
+      - name: Drop markdown.html
+        uses: PJ-568/[email protected]
 
-    - name: Setup Pages
-      uses: actions/configure-pages@v4
+      - name: Setup Pages
+        uses: actions/configure-pages@v4
 
-    - name: Upload artifact
-      uses: actions/upload-pages-artifact@v3
-      with:
-        path: './'
+      - name: Upload artifact
+        uses: actions/upload-pages-artifact@v3
+        with:
+          path: "./"
 
-    - name: Deploy to GitHub Pages
-      id: deployment
-      uses: actions/deploy-pages@v4
+      - name: Deploy to GitHub Pages
+        id: deployment
+        uses: actions/deploy-pages@v4
 
-    - name: Delete tag
-      if: (cancelled() || failure()) && steps.push-tag.outputs.tag_name != ''
-      run: |
-        git config user.name "${GITHUB_ACTOR}"
-        git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
-        git push --delete origin "${{ steps.push-tag.outputs.tag_name }}"
-        git tag -d "${{ steps.push-tag.outputs.tag_name }}"
+      - name: Delete tag
+        if: (cancelled() || failure()) && steps.push-tag.outputs.tag_name != ''
+        run: |
+          git config user.name "${GITHUB_ACTOR}"
+          git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
+          git push --delete origin "${{ steps.push-tag.outputs.tag_name }}"
+          git tag -d "${{ steps.push-tag.outputs.tag_name }}"

+ 1 - 1
README.md

@@ -1,4 +1,4 @@
-# PJ568 提交说明规范 `v0.2.2`
+# PJ568 提交说明规范 `v0.2.3`
 
 本规范旨在格式化提交说明,以在方便阅读理解的同时,保证其能被程序一致地解析。