fix: 当 BLOG_POST_DIRECTORY
为空或当前目录时,将会扫描系统根目录中的文件
#13
Workflow file for this run
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: PR CI checks | |
on: | |
pull_request: | |
types: [synchronize, opened] | |
branches: | |
- master | |
jobs: | |
lint_project: | |
runs-on: ubuntu-latest | |
name: 'Lint project' | |
permissions: | |
contents: write | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
cache: 'npm' | |
cache-dependency-path: package-lock.json | |
- name: Install Dependencies | |
run: 'npm install' | |
- name: Run lint | |
id: lint_result | |
run: | | |
#!/bin/bash | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
if [ $? -ne 0 ]; then | |
exit $? | |
fi | |
git add . | |
status=`git status --short | wc -l` | |
if [ $status -eq 0 ]; then | |
exit 0 | |
fi | |
git commit -m "chore: lint project" | |
git push origin $BRANCH | |
status=$? | |
if [ $status -ne 0 ]; then | |
exit $status | |
fi | |
echo "changed=1" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BRANCH: ${{ github.event.pull_request.head.ref }} | |
outputs: | |
changed: ${{ job.lint_project.stpes.lint_result.changed }} | |
run_unit_test: | |
name: 'Run unit test' | |
runs-on: ubuntu-latest | |
needs: lint_project | |
if: ${{ needs.lint_project.outputs.changed == 0 }} | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
cache: 'npm' | |
cache-dependency-path: package-lock.json | |
- name: Install Dependencies | |
run: 'npm install' | |
- name: Run test | |
run: npm run test | |