ci: git hooks add prettier eslint #30
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
name: Build and Deploy | |
on: # 监听 main 分支上的 push 事件 | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest # 构建环境使用 ubuntu | |
steps: | |
# 下载源码 | |
- name: Checkout | |
uses: actions/checkout@v2 | |
# 设置 Node.js 环境 | |
- name: Set up Node.js | |
uses: actions/setup-node@master | |
with: | |
node-version: '20.x' | |
# 安装依赖 | |
- name: Install dependencies | |
run: npm install | |
# 运行代码质量检查(只检测) | |
- name: Run ESLint and Prettier | |
# run: | | |
# npx eslint . --fix | |
# npx prettier --check . | |
run: | | |
npx eslint . --max-warnings=0 | |
npx prettier --check . | |
# 运行测试 | |
- name: Run tests | |
run: npm test | |
# 打包项目 | |
- name: Build project | |
run: npm run build | |
- name: Verify build output | |
run: cat dist/index.html | |
- name: Deploy # 将打包内容发布到 github page | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
branch: gh-pages | |
publish_dir: ./dist | |
github_token: ${{ secrets.VUE_ADMIN }} # secert 名 | |
user_name: ${{ secrets.MY_USER_NAME }} # 通过 Secrets 配置 | |
user_email: ${{ secrets.MY_USER_EMAIL }} # 通过 Secrets 配置 | |
commit_message: 自动部署 | |
# - name: Disable Jekyll | |
# run: echo '' > ./dist/.nojekyll | |
# ·-name:·发布到阿里云 | |
# uses:easingthemes/ssh-deployav2.1.1 | |
# env: | |
# ·#私钥 | |
# SSH_PRIVATE_KEY:${{secrets.PRIVATE_KEY} | |
# #:scp参数 | |
# ARGS:'-avzr.--delete' | |
# #·源目录 | |
# SOURCE:·'dist' | |
# #~服务器ip:换成你的服务器IP | |
# REMOTE_HOST:${{secrets.REMOTE_HOST-} | |
# #用户 | |
# REMOTE USER:·'root' | |
# #目标地址 | |
# -TARGET:-'/wwww/wwwroot' | |
# # 运行测试并生成覆盖率报告 | |
# - name: Run tests with coverage | |
# run: npm run test | |
# # 上传覆盖率报告到 Codecov | |
# - name: Upload coverage to Codecov | |
# uses: codecov/codecov-action@v3 | |
# with: | |
# token: ${{ secrets.CODECOV_TOKEN }} | |
# files: ./coverage/lcov.info | |
# flags: unittests | |
# name: Codecov-Example |