-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Lint Check | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
style: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.1' | ||
extensions: mbstring, bcmath | ||
tools: composer:v2 | ||
|
||
- name: Install Dependencies | ||
run: composer install --no-scripts --no-interaction --prefer-dist | ||
|
||
- name: Check code style with Pint | ||
run: | | ||
vendor/bin/pint --test | ||
if [ $? -eq 0 ]; then | ||
echo "✅ Code style is clean" | ||
else | ||
echo "❌ Code style issues found" | ||
vendor/bin/pint --verbose | ||
exit 1 | ||
fi | ||
- name: Add Lint Results as PR Comment | ||
if: github.event_name == 'pull_request' && failure() | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const output = ` | ||
## ⚠️ PHP Code Style Check Failed | ||
Please fix the code style issues found by Laravel Pint. | ||
Run \`composer lint\` locally to see and fix the issues. | ||
For more information about Laravel Pint, visit: https://laravel.com/docs/pint | ||
`; | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: output | ||
}) |
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