Skip to content

Commit 6847b99

Browse files
committed
Merge branch 'formatting-ci' into ci-integraton-and-fixes
2 parents 961be12 + dbb8f09 commit 6847b99

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4
1717
with:
18-
ref: ${{ github.head_ref }}
1918
token: ${{ secrets.GITHUB_TOKEN }}
20-
19+
2120
- name: Setup Node.js
2221
uses: actions/setup-node@v4
2322
with:
@@ -32,9 +31,21 @@ jobs:
3231

3332
- name: Format code
3433
run: npm run format
35-
34+
35+
# For pushes to main or PRs from same repo, commit formatting changes
3636
- name: Commit changes
37+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
3738
uses: stefanzweifel/git-auto-commit-action@v5
3839
with:
3940
commit_message: "style: format code with prettier"
40-
branch: ${{ github.head_ref }}
41+
branch: ${{ github.event_name == 'push' && 'main' || github.head_ref }}
42+
43+
# For PRs from forks, fail the check if there are formatting changes required
44+
- name: Check for uncommitted changes
45+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
46+
run: |
47+
if [[ -n "$(git status --porcelain)" ]]; then
48+
echo "::error::Code formatting issues found. Please run 'npm run format' locally and commit the changes."
49+
git diff
50+
exit 1
51+
fi

0 commit comments

Comments
 (0)