Merge pull request #154 from ChetanXpro/dependabot/npm_and_yarn/types… #286
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: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
- name: Run type check | |
run: npm run typecheck | |
- name: Format code | |
run: npm run format | |
# For pushes to main or PRs from same repo, commit formatting changes | |
- name: Commit changes | |
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "style: format code with prettier" | |
branch: ${{ github.event_name == 'push' && 'main' || github.head_ref }} | |
# For PRs from forks, fail the check if there are formatting changes required | |
- name: Check for uncommitted changes | |
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository | |
run: | | |
if [[ -n "$(git status --porcelain)" ]]; then | |
echo "::error::Code formatting issues found. Please run 'npm run format' locally and commit the changes." | |
git diff | |
exit 1 | |
fi |