Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Warning Annotation to GitHub Actions Logs #41

Merged
merged 3 commits into from
Oct 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/lineage/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,16 @@ def get_code_owners(repo: Repository.Repository) -> Generator[str, None, None]:
break


def has_existing_pr(repo: Repository.Repository, branch_name: str) -> bool:
"""Check if an open PR already exists for the lineage branch."""
# By default only open Pull Requests are returned
pull_requests = repo.get_pulls()
for pr in pull_requests:
if pr.head.ref == branch_name:
return True
return False


def main() -> None:
"""Parse environment and perform requested actions."""
# Set up logging. Force logging output to stdout to allow for GitHub Actions
Expand Down Expand Up @@ -412,6 +422,12 @@ def main() -> None:
repo, lineage_id, local_branch
)
logging.info("Pull request branch is new: %s", branch_is_new)
# If the branch already exists, then check if a PR exists
if not branch_is_new and not has_existing_pr(repo, pr_branch_name):
core.warning(
"There is no pull request for the existing Lineage branch.",
title=repo.full_name,
)
fetch(repo, remote_url, remote_branch)
changed: bool
conflict_file_list: List[str]
Expand Down