Update README
This commit is contained in:
parent
5077e8d6bd
commit
0e70fec054
47
README.md
47
README.md
|
@ -128,6 +128,53 @@ This configuration will create pull requests that look like this:
|
|||
|
||||
![Pull Request Example](https://github.com/peter-evans/create-pull-request/blob/master/pull-request-example.png?raw=true)
|
||||
|
||||
|
||||
### Example usage with 'on: pull_request' workflows
|
||||
|
||||
The following is an example workflow for a use-case where [autopep8](https://github.com/peter-evans/autopep8) action runs as both a check on pull requests and raises a further pull request to apply code fixes.
|
||||
|
||||
How it works:
|
||||
1. When a pull request is raised the workflow executes as a check
|
||||
2. If autopep8 makes any fixes a pull request will be raised for those fixes to be merged into the current pull request branch. The workflow then deliberately causes the check to fail.
|
||||
3. When the pull request containing the fixes is merged the workflow runs again. This time autopep8 makes no changes and the check passes.
|
||||
4. The original pull request can now be merged.
|
||||
|
||||
```yml
|
||||
name: autopep8
|
||||
on: pull_request
|
||||
jobs:
|
||||
autopep8:
|
||||
if: startsWith(github.head_ref, 'autopep8-patches') == false
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: autopep8
|
||||
id: autopep8
|
||||
uses: peter-evans/autopep8@v1.1.0
|
||||
with:
|
||||
args: --exit-code --recursive --in-place --aggressive --aggressive .
|
||||
- name: Set autopep8 branch name
|
||||
id: vars
|
||||
run: echo ::set-output name=branch-name::"autopep8-patches/$GITHUB_HEAD_REF"
|
||||
- name: Create Pull Request
|
||||
if: steps.autopep8.outputs.exit-code == 2
|
||||
uses: peter-evans/create-pull-request@v1.5.2
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
COMMIT_MESSAGE: autopep8 action fixes
|
||||
COMMIT_AUTHOR_EMAIL: peter-evans@users.noreply.github.com
|
||||
COMMIT_AUTHOR_NAME: Peter Evans
|
||||
PULL_REQUEST_TITLE: Fixes by autopep8 action
|
||||
PULL_REQUEST_BODY: This is an auto-generated PR with fixes by autopep8.
|
||||
PULL_REQUEST_LABELS: autopep8, automated pr
|
||||
PULL_REQUEST_REVIEWERS: peter-evans
|
||||
PULL_REQUEST_BRANCH: ${{ steps.vars.outputs.branch-name }}
|
||||
BRANCH_SUFFIX: none
|
||||
- name: Fail if autopep8 made changes
|
||||
if: steps.autopep8.outputs.exit-code == 2
|
||||
run: exit 1
|
||||
```
|
||||
|
||||
### Dynamic configuration using variables
|
||||
|
||||
The following examples show how configuration for the action can be dynamically defined in a previous workflow step.
|
||||
|
|
Loading…
Reference in a new issue