Merge branch 'multi-platform' into multi-platform-release

This commit is contained in:
Peter Evans 2019-10-30 16:09:06 +09:00
commit 95ff720144
3 changed files with 95 additions and 108 deletions

View file

@ -18,7 +18,7 @@ Create Pull Request action will:
Linux Linux
```yml ```yml
- name: Create Pull Request - name: Create Pull Request
uses: peter-evans/create-pull-request@v1.5.3 uses: peter-evans/create-pull-request@v1.5.4
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```
@ -26,7 +26,7 @@ Linux
Multi platform - Linux, MacOS, Windows (beta) Multi platform - Linux, MacOS, Windows (beta)
```yml ```yml
- name: Create Pull Request - name: Create Pull Request
uses: peter-evans/create-pull-request@v1.5.3-multi uses: peter-evans/create-pull-request@v1.5.4-multi
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```
@ -105,7 +105,7 @@ jobs:
- name: Create report file - name: Create report file
run: date +%s > report.txt run: date +%s > report.txt
- name: Create Pull Request - name: Create Pull Request
uses: peter-evans/create-pull-request@v1.5.3 uses: peter-evans/create-pull-request@v1.5.4
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_MESSAGE: Add report file COMMIT_MESSAGE: Add report file
@ -157,7 +157,7 @@ jobs:
ncu -u ncu -u
npm install npm install
- name: Create Pull Request - name: Create Pull Request
uses: peter-evans/create-pull-request@v1.5.3 uses: peter-evans/create-pull-request@v1.5.4
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_MESSAGE: update dependencies COMMIT_MESSAGE: update dependencies
@ -201,7 +201,7 @@ jobs:
run: echo ::set-output name=branch-name::"autopep8-patches/$GITHUB_HEAD_REF" run: echo ::set-output name=branch-name::"autopep8-patches/$GITHUB_HEAD_REF"
- name: Create Pull Request - name: Create Pull Request
if: steps.autopep8.outputs.exit-code == 2 if: steps.autopep8.outputs.exit-code == 2
uses: peter-evans/create-pull-request@v1.5.3 uses: peter-evans/create-pull-request@v1.5.4
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_MESSAGE: autopep8 action fixes COMMIT_MESSAGE: autopep8 action fixes
@ -232,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) \ 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)." by [create-pull-request](https://github.com/peter-evans/create-pull-request)."
- name: Create Pull Request - name: Create Pull Request
uses: peter-evans/create-pull-request@v1.5.3 uses: peter-evans/create-pull-request@v1.5.4
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_TITLE: ${{ steps.vars.outputs.pr_title }} PULL_REQUEST_TITLE: ${{ steps.vars.outputs.pr_title }}
@ -248,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) \ 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)." by [create-pull-request](https://github.com/peter-evans/create-pull-request)."
- name: Create Pull Request - name: Create Pull Request
uses: peter-evans/create-pull-request@v1.5.3 uses: peter-evans/create-pull-request@v1.5.4
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```

View file

@ -19,15 +19,6 @@ def get_github_event(github_event_path):
return github_event return github_event
def ignore_event(event_name, event_data):
if event_name == "push":
ref = "{ref}".format(**event_data)
if not ref.startswith('refs/heads/'):
print("Ignoring events for tags and remotes.")
return True
return False
def get_head_short_sha1(repo): def get_head_short_sha1(repo):
return repo.git.rev_parse('--short', 'HEAD') return repo.git.rev_parse('--short', 'HEAD')
@ -90,10 +81,7 @@ def cs_string_to_list(str):
return list(filter(None, l)) return list(filter(None, l))
def process_event(event_name, event_data, repo, branch, base, remote_exists): def process_event(github_token, github_repository, repo, branch, base, remote_exists):
# Fetch required environment variables
github_token = os.environ['GITHUB_TOKEN']
github_repository = os.environ['GITHUB_REPOSITORY']
# Fetch optional environment variables with default values # Fetch optional environment variables with default values
commit_message = os.getenv( commit_message = os.getenv(
'COMMIT_MESSAGE', 'COMMIT_MESSAGE',
@ -111,9 +99,6 @@ def process_event(event_name, event_data, repo, branch, base, remote_exists):
pull_request_reviewers = os.environ.get('PULL_REQUEST_REVIEWERS') pull_request_reviewers = os.environ.get('PULL_REQUEST_REVIEWERS')
pull_request_team_reviewers = os.environ.get('PULL_REQUEST_TEAM_REVIEWERS') pull_request_team_reviewers = os.environ.get('PULL_REQUEST_TEAM_REVIEWERS')
# Update URL for the 'origin' remote
set_git_remote_url(repo.git, github_token, github_repository)
# Push the local changes to the remote branch # Push the local changes to the remote branch
print("Pushing changes.") print("Pushing changes.")
push_result = push_changes(repo.git, branch, commit_message) push_result = push_changes(repo.git, branch, commit_message)
@ -161,12 +146,14 @@ def process_event(event_name, event_data, repo, branch, base, remote_exists):
team_reviewers=cs_string_to_list(pull_request_team_reviewers)) team_reviewers=cs_string_to_list(pull_request_team_reviewers))
# Get the JSON event data # Fetch environment variables
github_token = os.environ['GITHUB_TOKEN']
github_repository = os.environ['GITHUB_REPOSITORY']
github_ref = os.environ['GITHUB_REF']
event_name = os.environ['GITHUB_EVENT_NAME'] event_name = os.environ['GITHUB_EVENT_NAME']
# Get the JSON event data
event_data = get_github_event(os.environ['GITHUB_EVENT_PATH']) event_data = get_github_event(os.environ['GITHUB_EVENT_PATH'])
# Check if this event should be ignored
skip_ignore_event = bool(os.environ.get('SKIP_IGNORE'))
if skip_ignore_event or not ignore_event(event_name, event_data):
# Set the repo to the working directory # Set the repo to the working directory
repo = Repo(os.getcwd()) repo = Repo(os.getcwd())
# Get the default for author email and name # Get the default for author email and name
@ -176,13 +163,13 @@ if skip_ignore_event or not ignore_event(event_name, event_data):
author_name = os.getenv('COMMIT_AUTHOR_NAME', author_name) author_name = os.getenv('COMMIT_AUTHOR_NAME', author_name)
# Set git configuration # Set git configuration
set_git_config(repo.git, author_email, author_name) set_git_config(repo.git, author_email, author_name)
# Update URL for the 'origin' remote
set_git_remote_url(repo.git, github_token, github_repository)
# Fetch/Set the branch name # Fetch/Set the branch name
branch_prefix = os.getenv( branch_prefix = os.getenv(
'PULL_REQUEST_BRANCH', 'PULL_REQUEST_BRANCH',
'create-pull-request/patch') 'create-pull-request/patch')
# Fetch the git ref
github_ref = os.environ['GITHUB_REF']
# Fetch an optional base branch override # Fetch an optional base branch override
base_override = os.environ.get('PULL_REQUEST_BASE') base_override = os.environ.get('PULL_REQUEST_BASE')
@ -247,8 +234,8 @@ if skip_ignore_event or not ignore_event(event_name, event_data):
if repo.is_dirty() or len(repo.untracked_files) > 0: if repo.is_dirty() or len(repo.untracked_files) > 0:
print("Repository has modified or untracked files.") print("Repository has modified or untracked files.")
process_event( process_event(
event_name, github_token,
event_data, github_repository,
repo, repo,
branch, branch,
base, base,

View file

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