Fix/publish workflow #20
This file contains hidden or 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 Checks | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
push: | |
branches: | |
- main | |
- 'feature/**' | |
- 'fix/**' | |
- 'chore/**' | |
- 'docs/**' | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
cache: 'npm' | |
cache-dependency-path: 'package/package-lock.json' | |
- name: Install dependencies | |
working-directory: ./package | |
run: npm ci | |
- name: Run tests | |
working-directory: ./package | |
run: npm test | |
validate: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
cache: 'npm' | |
cache-dependency-path: 'package/package-lock.json' | |
- name: Install dependencies | |
working-directory: ./package | |
run: npm ci | |
- name: Format code | |
id: format | |
working-directory: ./package | |
run: npm run format | |
- name: Commit formatting changes | |
if: success() | |
working-directory: ./package | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add . | |
git diff --quiet && git diff --staged --quiet || (git commit -m "style: format code" && git push) | |
- name: Type check | |
id: type-check | |
working-directory: ./package | |
run: npm run type-check || (echo "TypeScript errors found" && exit 1) |