Compare commits

...

23 Commits

Author SHA1 Message Date
bf9134205d Merge branch 'multi-platform' into multi-platform-release 2019-10-21 20:34:05 +09:00
3ebb3e5c35 Merge branch 'master' into multi-platform 2019-10-21 20:33:52 +09:00
e1e9dd3f1c Update image version 2019-10-21 20:32:02 +09:00
9e4b07e38d Merge branch 'multi-platform' into multi-platform-release 2019-10-21 20:23:12 +09:00
6b66a45740 Merge branch 'master' into multi-platform 2019-10-21 20:22:27 +09:00
8c2a43987b Add an override for the base branch 2019-10-21 20:17:31 +09:00
c5ff844b40 Update README 2019-10-21 18:42:39 +09:00
1f47cf3861 Update workflows 2019-10-21 18:31:14 +09:00
bcdc7ae6f9 Merge pull request #55 from peter-evans/renovate/pygithub-1.x
Update dependency PyGithub to v1.44
2019-10-19 22:58:42 +09:00
91ca84eab5 Update dependency PyGithub to v1.44 2019-10-19 08:44:24 +00:00
875d189c30 Update README 2019-10-14 18:09:59 +09:00
7c3f5f4833 Update README 2019-10-14 16:12:27 +09:00
7a7e797068 Update README 2019-10-14 16:11:09 +09:00
a41f37fc96 Update README 2019-10-14 16:09:58 +09:00
10554ac6c3 Update README 2019-10-14 15:59:21 +09:00
2439726cfe Update README 2019-10-14 15:51:08 +09:00
4f04f4efd9 Update workflows 2019-10-14 15:50:52 +09:00
32d0abbc7c Update README 2019-10-14 15:07:11 +09:00
ed5b8b1eea Update README 2019-10-14 12:38:52 +09:00
ea241dfc79 Update README 2019-10-14 12:37:36 +09:00
0e70fec054 Update README 2019-10-14 12:36:55 +09:00
5077e8d6bd Rename dockerhub description workflow 2019-10-14 10:26:25 +09:00
901e854f30 Update README 2019-10-14 02:02:55 +09:00
7 changed files with 121 additions and 20 deletions

View File

@ -1,7 +1,7 @@
name: create-pull-request workflow
on:
repository_dispatch:
types: [create-pull-request-multi]
name: create-pull-request workflow
jobs:
createPullRequest:
name: Testing on ${{ matrix.platform }}
@ -25,9 +25,12 @@ jobs:
COMMIT_AUTHOR_EMAIL: peter-evans@users.noreply.github.com
COMMIT_AUTHOR_NAME: Peter Evans
PULL_REQUEST_TITLE: '[Example] Add report file'
PULL_REQUEST_BODY: >
This PR is auto-generated by
[create-pull-request](https://github.com/peter-evans/create-pull-request).
PULL_REQUEST_BODY: |
New report
- Contains *today's* date
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
PULL_REQUEST_LABELS: report, automated pr
PULL_REQUEST_ASSIGNEES: peter-evans
PULL_REQUEST_REVIEWERS: peter-evans

View File

@ -1,7 +1,7 @@
name: create-pull-request workflow
on:
repository_dispatch:
types: [create-pull-request]
name: create-pull-request workflow
jobs:
createPullRequest:
runs-on: ubuntu-latest
@ -17,9 +17,12 @@ jobs:
COMMIT_AUTHOR_EMAIL: peter-evans@users.noreply.github.com
COMMIT_AUTHOR_NAME: Peter Evans
PULL_REQUEST_TITLE: '[Example] Add report file'
PULL_REQUEST_BODY: >
This PR is auto-generated by
[create-pull-request](https://github.com/peter-evans/create-pull-request).
PULL_REQUEST_BODY: |
New report
- Contains *today's* date
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
PULL_REQUEST_LABELS: report, automated pr
PULL_REQUEST_ASSIGNEES: peter-evans
PULL_REQUEST_REVIEWERS: peter-evans

108
README.md
View File

@ -18,7 +18,7 @@ Create Pull Request action will:
Linux
```yml
- name: Create Pull Request
uses: peter-evans/create-pull-request@v1.5.1
uses: peter-evans/create-pull-request@v1.5.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
@ -26,7 +26,7 @@ Linux
Multi platform - Linux, MacOS, Windows (beta)
```yml
- name: Create Pull Request
uses: peter-evans/create-pull-request@v1.5.1-multi
uses: peter-evans/create-pull-request@v1.5.2-multi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
@ -51,6 +51,7 @@ These variables are *all optional*. If not set, sensible default values will be
| `PULL_REQUEST_TEAM_REVIEWERS` | A comma separated list of GitHub teams to request a review from. | none |
| `PULL_REQUEST_MILESTONE` | The number of the milestone to associate this pull request with. | none |
| `PULL_REQUEST_BRANCH` | The branch name. See **Branch naming** below for details. | `create-pull-request/patch` |
| `PULL_REQUEST_BASE` | Overrides the base branch. **Use with caution!** | Defaults to the currently checked out branch. |
| `BRANCH_SUFFIX` | The branch suffix type. Valid values are `short-commit-hash`, `timestamp`, `random` and `none`. See **Branch naming** below for details. | `short-commit-hash` |
**Output environment variables**
@ -92,10 +93,10 @@ If there are files or directories you want to ignore you can simply add them to
Here is an example that sets all the main environment variables.
```yml
name: create-pull-request workflow
on:
repository_dispatch:
types: [create-pull-request]
name: create-pull-request workflow
jobs:
createPullRequest:
runs-on: ubuntu-latest
@ -104,16 +105,19 @@ jobs:
- name: Create report file
run: date +%s > report.txt
- name: Create Pull Request
uses: peter-evans/create-pull-request@v1.5.1
uses: peter-evans/create-pull-request@v1.5.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_MESSAGE: Add report file
COMMIT_AUTHOR_EMAIL: peter-evans@users.noreply.github.com
COMMIT_AUTHOR_NAME: Peter Evans
PULL_REQUEST_TITLE: '[Example] Add report file'
PULL_REQUEST_BODY: >
This PR is auto-generated by
[create-pull-request](https://github.com/peter-evans/create-pull-request).
PULL_REQUEST_BODY: |
New report
- Contains *today's* date
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
PULL_REQUEST_LABELS: report, automated pr
PULL_REQUEST_ASSIGNEES: peter-evans
PULL_REQUEST_REVIEWERS: peter-evans
@ -128,6 +132,92 @@ 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 workflow to automate periodic dependency updates
This example workflow executes once a week and will create a pull request for any dependency updates. This pattern will work well for updating any kind of static content from an external source.
```yml
name: Update Dependencies
on:
schedule:
- cron: '0 10 * * 1'
jobs:
update-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '10.x'
- name: Update dependencies
id: vars
run: |
npm install -g npm-check-updates
ncu -u
npm install
- name: Create Pull Request
uses: peter-evans/create-pull-request@v1.5.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_MESSAGE: update dependencies
COMMIT_AUTHOR_EMAIL: peter-evans@users.noreply.github.com
COMMIT_AUTHOR_NAME: Peter Evans
PULL_REQUEST_TITLE: Automated Dependency Updates
PULL_REQUEST_BODY: This is an auto-generated PR with dependency updates.
PULL_REQUEST_LABELS: dep-updates, automated pr
PULL_REQUEST_REVIEWERS: peter-evans
PULL_REQUEST_BRANCH: dep-updates
BRANCH_SUFFIX: none
```
### Example usage with "on: pull_request" workflows
The following is an example workflow for a use-case where [autopep8 action](https://github.com/peter-evans/autopep8) runs as both a check on pull requests and raises a further pull request to apply code fixes. This is a pattern that would work well for any automated code linting and fixing.
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.
@ -142,7 +232,7 @@ The recommended method is to use `set-output`. Note that the step where output v
echo ::set-output name=pr_body::"This PR was auto-generated on $(date +%d-%m-%Y) \
by [create-pull-request](https://github.com/peter-evans/create-pull-request)."
- name: Create Pull Request
uses: peter-evans/create-pull-request@v1.5.1
uses: peter-evans/create-pull-request@v1.5.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_TITLE: ${{ steps.vars.outputs.pr_title }}
@ -158,7 +248,7 @@ Since the action reads environment variables from the system, it's technically n
echo ::set-env name=PULL_REQUEST_BODY::"This PR was auto-generated on $(date +%d-%m-%Y) \
by [create-pull-request](https://github.com/peter-evans/create-pull-request)."
- name: Create Pull Request
uses: peter-evans/create-pull-request@v1.5.1
uses: peter-evans/create-pull-request@v1.5.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

View File

@ -184,12 +184,17 @@ if skip_ignore_event or not ignore_event(event_name, event_data):
# Set the base branch
github_ref = os.environ['GITHUB_REF']
if github_ref.startswith('refs/pull/'):
# Switch to the merging branch instead of the merge commit
base = os.environ['GITHUB_HEAD_REF']
# Reset to the merging branch instead of the merge commit
repo.git.checkout(base)
else:
base = github_ref[11:]
# Optional base override
base = os.getenv('PULL_REQUEST_BASE', base)
# Checkout the base branch
repo.git.checkout(base)
# Skip if the current branch is a PR branch created by this action
if base.startswith(branch):
print("Branch '%s' was created by this action. Skipping." % base)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 201 KiB

After

Width:  |  Height:  |  Size: 441 KiB

View File

@ -1,2 +1,2 @@
GitPython==3.0.3
PyGithub==1.43.8
PyGithub==1.44