Skip to content

Commit 330e894

Browse files
Merge pull request #36 from DevWizardHQ/fix/workflow-pr-trigger
fix: enable code quality workflow on pull requests
2 parents 3ad3191 + cff6b28 commit 330e894

1 file changed

Lines changed: 28 additions & 12 deletions

File tree

.github/workflows/code-quality.yml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ on:
1313
- '.github/workflows/code-quality.yml'
1414
- 'tsconfig.json'
1515
- 'package.json'
16-
# pull_request:
17-
# branches: [main, develop]
16+
pull_request:
17+
branches: [main, develop]
1818

1919
permissions:
20-
contents: write
20+
contents: read
2121

2222
jobs:
2323
quality-check:
@@ -27,9 +27,6 @@ jobs:
2727
steps:
2828
- name: Checkout code
2929
uses: actions/checkout@v6
30-
with:
31-
ref: ${{ github.head_ref }}
32-
token: ${{ secrets.GITHUB_TOKEN }}
3330

3431
- name: Setup Node.js
3532
uses: actions/setup-node@v6
@@ -40,17 +37,36 @@ jobs:
4037
- name: Install dependencies
4138
run: npm ci
4239

43-
# Auto-fix formatting on push to main/develop (not on PRs)
44-
# Exclude .github/ to avoid workflow permission issues
45-
- name: Format code
46-
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
47-
run: npx prettier --write . --ignore-path .prettierignore '!.github/**'
40+
- name: Check formatting
41+
run: npx prettier --check . --ignore-path .prettierignore '!.github/**'
4842

4943
- name: Run ESLint
5044
run: npm run lint
5145

46+
auto-format:
47+
name: Auto Format
48+
if: github.event_name == 'push'
49+
runs-on: ubuntu-latest
50+
timeout-minutes: 10
51+
permissions:
52+
contents: write
53+
steps:
54+
- name: Checkout code
55+
uses: actions/checkout@v6
56+
57+
- name: Setup Node.js
58+
uses: actions/setup-node@v6
59+
with:
60+
node-version: '20'
61+
cache: 'npm'
62+
63+
- name: Install dependencies
64+
run: npm ci
65+
66+
- name: Format code
67+
run: npx prettier --write . --ignore-path .prettierignore '!.github/**'
68+
5269
- name: Commit formatting changes
53-
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
5470
uses: stefanzweifel/git-auto-commit-action@v7
5571
with:
5672
commit_message: 'style: fix code formatting [skip ci]'

0 commit comments

Comments
 (0)