Create lint.yml (#25) #11
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: 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 | |
}) |