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

Get repo default branch if --branch not provided (containerapp up --repo) #75

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/containerapp/azext_containerapp/_up_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ def _get_dockerfile_content_from_repo( # pylint: disable=inconsistent-return-st
context_path = context_path or "."
repo = repo_url_to_name(repo_url)
r = g.get_repo(repo)
if not branch:
branch = r.default_branch
files = r.get_contents(context_path, ref=branch)
for f in files:
if f.path == dockerfile or f.path.endswith(f"/{dockerfile}"):
Expand Down
1 change: 1 addition & 0 deletions src/containerapp/azext_containerapp/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def await_github_action(cmd, token, repo, branch, name, resource_group_name, tim
animation.flush()
animation.tick()
animation.flush()
sleep(3) # adding sleep until there is a way of verifying index[0] is latest workflow run based on id/time
runs = workflow.get_runs()
while runs is None or runs.totalCount < 1:
runs = workflow.get_runs()
Expand Down
13 changes: 6 additions & 7 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,8 @@ def _validate_github(repo, branch, token):
if not github_repo.permissions.push or not github_repo.permissions.maintain:
raise ValidationError("The token does not have appropriate access rights to repository {}.".format(repo))
try:
if not branch:
branch = github_repo.default_branch
github_repo.get_branch(branch=branch)
except GithubException as e:
error_msg = "Encountered GitHub error when accessing {} branch in {} repo.".format(branch, repo)
Expand All @@ -1059,7 +1061,7 @@ def _validate_github(repo, branch, token):
if e.data and e.data['message']:
error_msg += " Error: {}".format(e.data['message'])
raise CLIInternalError(error_msg) from e

return branch

def create_or_update_github_action(cmd,
name,
Expand Down Expand Up @@ -1088,7 +1090,7 @@ def create_or_update_github_action(cmd,
repo = repo_url_to_name(repo_url)
repo_url = f"https://github.com/{repo}" # allow specifying repo as <user>/<repo> without the full github url

_validate_github(repo, branch, token)
branch = _validate_github(repo, branch, token)

source_control_info = None

Expand All @@ -1102,10 +1104,7 @@ def create_or_update_github_action(cmd,

source_control_info["properties"]["repoUrl"] = repo_url

if branch:
source_control_info["properties"]["branch"] = branch
if not source_control_info["properties"]["branch"]:
source_control_info["properties"]["branch"] = "main"
source_control_info["properties"]["branch"] = branch

azure_credentials = None

Expand Down Expand Up @@ -1995,7 +1994,7 @@ def containerapp_up(cmd,
logs_key=None,
repo=None,
token=None,
branch="main",
branch=None,
browse=False,
context_path=None,
service_principal_client_id=None,
Expand Down