From fcc56736a6d08ba156dc74a76e0dce52d92cdbe4 Mon Sep 17 00:00:00 2001 From: Derek Ardolf Date: Tue, 24 Sep 2019 00:56:53 -0700 Subject: [PATCH 1/2] Add skip_ignore arg to ignore_event function During testing, I found it useful to have this function skipped so I added a simple check for SKIP_IGNORE env variable --- create-pull-request.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/create-pull-request.py b/create-pull-request.py index 8d13e4c..f74159e 100755 --- a/create-pull-request.py +++ b/create-pull-request.py @@ -15,8 +15,8 @@ def get_github_event(github_event_path): return github_event -def ignore_event(event_name, event_data): - if event_name == "push": +def ignore_event(event_name, event_data, skip_ignore): + if event_name == "push" and not skip_ignore: # 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 @@ -122,7 +122,8 @@ def process_event(event_name, event_data, repo, branch, base): event_name = os.environ['GITHUB_EVENT_NAME'] event_data = get_github_event(os.environ['GITHUB_EVENT_PATH']) # Check if this event should be ignored -if not ignore_event(event_name, event_data): +skip_ignore_event = bool(os.environ.get('SKIP_IGNORE')) +if not ignore_event(event_name, event_data, skip_ignore_event): # Set the repo to the working directory repo = Repo(os.getcwd()) From 4fb3c76ad71de57fdb83aa56e32e10521dbf4c42 Mon Sep 17 00:00:00 2001 From: Derek Ardolf Date: Tue, 24 Sep 2019 01:08:16 -0700 Subject: [PATCH 2/2] Introduced SKIP_IGNORE env variable option If the SKIP_IGNORE env var is present, the ignore_event function will not run --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 683122f..15f0298 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ These variables are all optional. If not set, a default value will be used. - `COMMIT_MESSAGE` - The message to use when committing changes. - `PULL_REQUEST_TITLE` - The title of the pull request. - `PULL_REQUEST_BODY` - The body of the pull request. +- `SKIP_IGNORE` - If present, the `ignore_event` function will not run #### Branch naming @@ -52,7 +53,7 @@ If there are files or directories you want to ignore you can simply add them to ## Example -Here is an example that sets all the environment variables. +Here is an example that sets all the environment variables (except `SKIP_IGNORE`). ```yml - name: Create Pull Request