-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add lint.yaml * fix file pos * test * test2 * test3 * test4 * test5 * fix syntax & test5 * fix syntax & test6 * fix workflow * fix workflow 2 * fix workflow 3 * add exit code * fix exit code * remove test code --------- Co-authored-by: 王久扬 <[email protected]>
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: TypeScript, Vue.js, and CSS Formatting And Linting | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
paths: | ||
- "**.css" | ||
- "**.ts" | ||
- "**.vue" | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
format_and_lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.9.0' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Run Prettier | ||
run: npm run format | ||
|
||
- name: Run ESLint | ||
continue-on-error: true | ||
id: lint | ||
run: npx eslint src | ||
|
||
- name: Auto commit Prettier formatted files | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: "auto prettier format code" | ||
file_pattern: "*.css *.ts *.vue" # Don't update package-lock.json and package.json | ||
|
||
- name: Add PR review comment if eslint fails | ||
if: ${{ steps.lint.outcome == 'failure' }} | ||
uses: actions/github-script@v4 | ||
with: | ||
script: | | ||
const { pull_request } = context.payload; | ||
const comment = "Your code does not meet our eslint standards.\nPlease run `npm install eslint @eslint/js typescript-eslint eslint-plugin-vue globals && npx eslint src` to lint your code."; | ||
await github.issues.createComment({ | ||
issue_number: pull_request.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: comment | ||
}); | ||
core.setFailed("eslint failed") |