Skip to content

[IP-126]: implement peppol #147

[IP-126]: implement peppol

[IP-126]: implement peppol #147

Workflow file for this run

name: Laravel Pint
on:
workflow_dispatch: # Allows manual triggering
inputs:
mode:
description: 'Pint mode to run'
required: true
default: 'dirty'
type: choice
options:
- dirty
- full
pull_request:
branches:
- master
- develop
permissions:
contents: write
jobs:
pint:
name: Code Style Check with Laravel Pint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup PHP with Composer
uses: ./.github/actions/setup-php-composer
with:
php-version: '8.4'
composer-flags: '--prefer-dist --no-interaction --no-progress'
- name: Run Laravel Pint
id: pint_run
run: |
# Determine which mode to run
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
# PRs always run in dirty mode (only check changed files)
PINT_MODE="dirty"
echo "Running Laravel Pint in dirty mode (checking only changed files)..."
else
# Manual runs use the selected mode (default to dirty if not set)
PINT_MODE="${{ github.event.inputs.mode || 'dirty' }}"
if [[ "$PINT_MODE" == "full" ]]; then
echo "Running Laravel Pint in full mode (this may take over 2 minutes)..."
else
echo "Running Laravel Pint in dirty mode (checking only changed files)..."
fi
fi
set +e # Don't exit on error
if [[ "$PINT_MODE" == "dirty" ]]; then
vendor/bin/pint --dirty 2>&1 | tee pint_output.log
else
vendor/bin/pint 2>&1 | tee pint_output.log
fi
PINT_EXIT_CODE=${PIPESTATUS[0]}
set -e # Re-enable exit on error
# Store exit code for later steps
echo "exit_code=$PINT_EXIT_CODE" >> $GITHUB_OUTPUT
# Check if there were parse errors
if grep -q "Parse error" pint_output.log || grep -q "!" pint_output.log; then
echo "parse_errors=true" >> $GITHUB_OUTPUT
echo "WARNING: Parse errors detected in one or more files"
else
echo "parse_errors=false" >> $GITHUB_OUTPUT
fi
# Don't fail the step - we want to commit successfully formatted files
exit 0
- name: Check for changes
id: verify_diff
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "✓ Files were modified by Pint"
git status --short
else
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "✓ No files were modified"
fi
- name: Commit and Push Changes
if: steps.verify_diff.outputs.has_changes == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -A
git commit -m "style: apply Laravel Pint fixes" --no-verify
git push
if [[ "${{ steps.pint_run.outputs.parse_errors }}" == "true" ]]; then
echo "WARNING: Changes committed successfully, but some files had parse errors and were not formatted"
echo "Please fix the parse errors in the files marked with '!' in the Pint output above"
else
echo "SUCCESS: All changes committed and pushed successfully"
fi
- name: Report Parse Errors
if: steps.pint_run.outputs.parse_errors == 'true'
run: |
echo "❌ Pint encountered parse errors in one or more files"
echo "Files with parse errors are marked with '!' in the output above"
echo "Successfully formatted files have been committed, but files with parse errors were skipped"
echo ""
echo "To fix:"
echo "1. Review the Pint output above to identify files with parse errors"
echo "2. Fix the syntax errors in those files"
echo "3. Re-run this workflow"
exit 1