This repository has been archived by the owner on May 30, 2024. It is now read-only.
Bump aglipanci/laravel-pint-action from 2.3.1 to 2.4 #15
Workflow file for this run
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: Fix PHP code style issues | |
on: [pull_request] | |
env: | |
PR_NUMBER: '${{ github.event.number }}' | |
SOURCE_BRANCH: '$GITHUB_HEAD_REF' | |
FIXER_BRANCH: 'auto-fixed/$GITHUB_HEAD_REF' | |
TITLE: 'Format PHP code' | |
DESCRIPTION: 'This merge request applies code style fixes from an analysis carried out through GitHub Actions.' | |
permissions: | |
contents: write | |
jobs: | |
php-code-styling: | |
if: github.event_name == 'pull_request' && ! startsWith(github.ref, 'refs/heads/auto-fixed/') | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Prepare Git User | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git checkout -B "${{ env.FIXER_BRANCH }}" | |
- name: Fix PHP code style issues | |
uses: aglipanci/[email protected] | |
- name: Create Fixer PR | |
run: | | |
if [[ -z $(git status --porcelain) ]]; then | |
echo "Nothing to fix.. Exiting." | |
exit 0 | |
fi | |
OPEN_PRS=`curl --silent -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open"` | |
OPEN_FIXER_PRS=`echo ${OPEN_PRS} | grep -o "\"ref\": \"${{ env.FIXER_BRANCH }}\"" | wc -l` | |
git commit -am "${{ env.TITLE }}" | |
git push origin "${{ env.FIXER_BRANCH }}" --force | |
if [ ${OPEN_FIXER_PRS} -eq "0" ]; then | |
curl -X POST \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/$GITHUB_REPOSITORY/pulls" \ | |
-d "{ \"head\":\"${{ env.FIXER_BRANCH }}\", \"base\":\"${{ env.SOURCE_BRANCH }}\", \"title\":\"${{ env.TITLE }}\", \"body\":\"${{ env.DESCRIPTION }}\n\nTriggered by #${{ env.PR_NUMBER }}\" }" | |
fi |