Closed thedrow closed 4 years ago
I think the workflow you describe is totally doable. To be honest, the main reason I put this autopep8 action together (which is just a simple wrapper) was to test and showcase another action I wrote, create-pull-request. That can be used for a similar workflow:
I should probably improve the README and add some more realistic example workflows.
I worked on this and updated the README with a more realistic workflow similar to the one you describe. Had to make some changes to the action and expose the exit code of autopep8 for it to work.
I also had a think about your suggestion to commit directly to the branch and remembered why it wouldn't work so well. There is a deliberate limitation imposed by GitHub Actions that an action cannot trigger other workflows. From the documentation:
An action in a workflow run can't trigger a new workflow run. For example, if an action pushes code using the repository's GITHUB_TOKEN, a new workflow will not run even when the repository contains a workflow configured to run when push events occur.
https://help.github.com/en/articles/events-that-trigger-workflows#example-using-more-than-one-event
I contacted GitHub support for clarification on a similar issue that you can read about here. https://github.com/peter-evans/create-pull-request/issues/48
So what would happen is that when you commit the fixed code directly to the pull request branch, that event would not trigger the on: pull_request
checks to run again. I think this is why having it raise a PR works better. The action of merging the PR allows the on: pull_request
checks to run again and verify that the original PR passes the autopep8 check.
That's exactly why I'm not giving up on other CI services and use actions only for automation.
I have a workflow example for direct push to the pull request branch working. Please see the following section of the README.
https://github.com/peter-evans/autopep8#direct-push-with-on-pull_request-workflows
Yes that works wonderfully!
Here's the workflow I've been thinking about introducing to my repositories: 1) Someone opens a PR. 2) This action is run. 3) We push the correctly formatted code to their branch if the branch isn't their master branch.
The github-push-action can assist us in doing so. Would you like me to try and let you know if that workflow works?