GithubHelp home page GithubHelp logo

Comments (10)

mpdude avatar mpdude commented on September 22, 2024 2

Let's give it a try:

on: [push]
name: Create PRs for php-cs-fixer fixups

jobs:
    fix-cs:
        name: Fix CS violations
        runs-on: ubuntu-18.04
        steps:
            - uses: actions/checkout@v2
            - uses: docker://oskarstark/php-cs-fixer-ga:latest
            - uses: peter-evans/create-pull-request@v2
              id: cpr
              with:
                  token: ${{ secrets.GITHUB_TOKEN }}
                  commit-message: Apply php-cs-fixer changes as of ${{ github.sha }}
                  title: Fix coding standards in ${{ github.ref }}
                  branch: php-cs-fixer/${{ github.ref }}
                  assignees: ${{ github.actor }}
                  body: |
                    Please apply these changes on the ${{ github.ref }} branch to fix coding standard violations.

            - uses: unsplash/[email protected]
              env:
                  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
              if: steps.cpr.outputs.pr_number
              continue-on-error: true # Will fail if not on PR
              with:
                  msg: |
                    @${{ github.actor }} please apply the coding standard fixes from #${{ steps.cpr.outputs.pr_number }}

This will monitor all pushed commits. Whenever a commit violates CS,

  • create a branch named php-cs-fixer/ + the name of the branch with the bogus commits
  • (force) push necessary changes there
  • Open a PR, to merge that branch into the offending branch
  • If the offending branch has a corresponding PR open, add a comment in it to point to the fixups

Only downside: If a branch or PR violates CS, the status checks will be green, regardless of whether a fix is necessary or not.

Update: I'll try to maintain an up-to-date version of this at https://gist.github.com/mpdude/ca93a185bcbf56eb7e341632ad4f8263

from php-cs-fixer-ga.

staabm avatar staabm commented on September 22, 2024 1

I guess this would be easy to achieve using https://github.com/peter-evans/create-pull-request

Might only need a example config

from php-cs-fixer-ga.

staabm avatar staabm commented on September 22, 2024 1

Totally I agree. This issue can be closed (it is opened from my corporate user account)

from php-cs-fixer-ga.

OskarStark avatar OskarStark commented on September 22, 2024

Not yet but you can run the docker command locally from the readme to fix the issues, so that you don’t need that dependency in your composer.json file

from php-cs-fixer-ga.

staabm avatar staabm commented on September 22, 2024

after using some other Github Actions as a 'end-user' it seems to me that a comment triggered action command would be best for this.

something like: when a comment is posted to a pull request which contains /fix-cs let the action run, fix the code and push to this pull request.

inspiration can be taken from e.g. https://github.com/cirrus-actions/rebase which does that with a different command.

I have no experience with docker or authoring github actions, therefore won't tackle it myself in the next weeks/months though.

from php-cs-fixer-ga.

OskarStark avatar OskarStark commented on September 22, 2024

Nice idea

from php-cs-fixer-ga.

OskarStark avatar OskarStark commented on September 22, 2024

Nice idea

from php-cs-fixer-ga.

simonschaufi avatar simonschaufi commented on September 22, 2024

I have found this github action here that actually also fixes code style: https://github.com/christophrumpel/laravel-factories-reloaded/blob/master/.github/workflows/run-styles.yml and this blog article: https://stefanzweifel.io/posts/run-prettier-or-php-cs-fixer-with-github-actions/#run-php-cs-fixer

from php-cs-fixer-ga.

staabm avatar staabm commented on September 22, 2024

We are using something similar in the meantime
https://github.com/redaxo/redaxo/blob/master/.github/workflows/cs-fix.yml

from php-cs-fixer-ga.

OskarStark avatar OskarStark commented on September 22, 2024

TBH it does not feel right do add all the needed code to this repository.

@localheinz and me are using Stefan Zweifel’s GitHub Action to commit changed files afterwards. You can do so much more like using a dedicated bot 🤖 User etc.

from php-cs-fixer-ga.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.