Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
7980880191 | |||
4efcea62da | |||
580fc69c02 | |||
facb42d776 | |||
37fd4d3558 | |||
bc78d4cf02 | |||
91ff2766bf | |||
c216905beb | |||
045ccaa641 | |||
a26e9f2362 |
13
README.md
13
README.md
@ -13,18 +13,20 @@ Create Pull Request action will:
|
||||
2. Commit all changes to a new branch. The commit will be made using the name and email of the `HEAD` commit author.
|
||||
3. Create a pull request to merge the new branch into the currently active branch executing the workflow.
|
||||
|
||||
Note: In general, it's not good practice to modify your repository during workflows.
|
||||
Note: Modifying a repository during workflows is not good practice in general.
|
||||
However, this action opens up some interesting possibilities when used carefully.
|
||||
This action is experimental and may not work well for repositories that have a very high frequency of commits.
|
||||
|
||||
## Usage
|
||||
|
||||
The default `GITHUB_TOKEN` does not have the access neccessary for this action to work correctly.
|
||||
Create a new `repo` scoped token [here](https://github.com/settings/tokens) and pass that as a secret to the `REPO_ACCESS_TOKEN` environment variable.
|
||||
In addition to the default `GITHUB_TOKEN`, the action requires a `repo` scoped token in order to commit.
|
||||
Create one [here](https://github.com/settings/tokens) and pass that as a secret to the `REPO_ACCESS_TOKEN` environment variable.
|
||||
|
||||
```yml
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v1.0.0
|
||||
uses: peter-evans/create-pull-request@v1.1.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
|
||||
```
|
||||
|
||||
@ -58,8 +60,9 @@ Here is an example that sets all the environment variables.
|
||||
|
||||
```yml
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v1.0.0
|
||||
uses: peter-evans/create-pull-request@v1.1.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
|
||||
PULL_REQUEST_BRANCH: my-patches
|
||||
COMMIT_MESSAGE: Auto-modify files by my-file-modifier-action
|
||||
|
@ -15,6 +15,9 @@ def get_github_event(github_event_path):
|
||||
|
||||
|
||||
def ignore_event(github_event):
|
||||
if 'schedule' in github_event:
|
||||
print("Allow schedule event.")
|
||||
return False
|
||||
# Ignore push events on deleted branches
|
||||
# The event we want to ignore occurs when a PR is created but the repository owner decides
|
||||
# not to commit the changes. They close the PR and delete the branch. This creates a
|
||||
@ -24,6 +27,10 @@ def ignore_event(github_event):
|
||||
if deleted == "True":
|
||||
print("Ignoring delete branch event.")
|
||||
return True
|
||||
ref = "{ref}".format(**github_event)
|
||||
if not ref.startswith('refs/heads/'):
|
||||
print("Ignoring events for tags and remotes.")
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@ -35,8 +42,12 @@ def pr_branch_exists(repo, branch):
|
||||
|
||||
|
||||
def get_head_author(github_event):
|
||||
email = "{head_commit[author][email]}".format(**github_event)
|
||||
name = "{head_commit[author][name]}".format(**github_event)
|
||||
if 'schedule' in github_event:
|
||||
email=os.environ['GITHUB_ACTOR']
|
||||
name=os.environ['GITHUB_ACTOR'] + '@users.noreply.github.com'
|
||||
else:
|
||||
email = "{head_commit[author][email]}".format(**github_event)
|
||||
name = "{head_commit[author][name]}".format(**github_event)
|
||||
return email, name
|
||||
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
GitPython==3.0.0
|
||||
GitPython==3.0.2
|
||||
PyGithub==1.43.8
|
Reference in New Issue
Block a user