fix: Build step in GitHub Actions workflow #3
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: CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' # Set the Node.js version | |
- name: Install dependencies | |
run: npm install | |
- name: Build project | |
run: npm run build # Ensure TypeScript files are compiled | |
- name: Lint code | |
run: npm run lint | |
- name: Format code | |
run: npm run format | |
- name: Run tests | |
run: npm test | |
- name: Generate test coverage report | |
run: npm run test -- --coverage | |
- name: Publish to npm | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
run: | | |
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} | |
npm publish | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |