I want to automate code formatting with php-cs-fixer using Github Actions #24629
-
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
(post deleted by author) |
Beta Was this translation helpful? Give feedback.
-
gensui0530:
You can get the event payload from the For a push you can get the commit before and after, or for a PR the head (or temporary merge) and base commits, and compare them. Note that by default |
Beta Was this translation helpful? Give feedback.
-
Thanks! I would like to run the following command only on files that have been changed within the PR.
github.event to get the event payload from the object or Is it possible to achieve this with these? |
Beta Was this translation helpful? Give feedback.
-
gensui0530:
If you can apply your tool to a list of files, yes. Once you have the two commits you want to compare you can use The most effort will probably be to get the right commit IDs to compare. For a For a |
Beta Was this translation helpful? Give feedback.
If you can apply your tool to a list of files, yes. Once you have the two commits you want to compare you can use
git diff --name-only
to get a list of files that changed between them.The most effort will probably be to get the right commit IDs to compare.
For a
push
event it’s fairly easy at a glance with thebefore
andafter
fields, except in case of a force-push (in that case thebefore
commit won’t be part of the branch history any more).For a
pull_request
you need to decide what you want to compare: There’s the base branch (probably a given), but do you want to compare to the head branch (that’s supposed to get merged) or …