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

Support private repo #285

Closed
wants to merge 6 commits 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 environment.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ GITHUB_SECRET=
GITHUB_LOGIN=
# GitHub oauth token
GITHUB_TOKEN=
# Repo is private
GITHUB_REPO_PRIVATE=True
# Coma separated list of github organisations names (for organization wide scheduled tasks)
#GITHUB_ORG=
# Git name and email used for creating commits (default: user git config,
Expand Down
1 change: 1 addition & 0 deletions src/oca_github_bot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def func_wrapper(*args, **kwargs):
GITHUB_ORG = (
os.environ.get("GITHUB_ORG") and os.environ.get("GITHUB_ORG").split(",") or []
)
GITHUB_REPO_PRIVATE = os.environ.get("GITHUB_REPO_PRIVATE")
GIT_NAME = os.environ.get("GIT_NAME")
GIT_EMAIL = os.environ.get("GIT_EMAIL")

Expand Down
4 changes: 3 additions & 1 deletion src/oca_github_bot/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ def temporary_clone(org, repo, branch):
if not os.path.isdir(repo_cache_dir):
os.makedirs(repo_cache_dir)
check_call(["git", "init", "--bare"], cwd=repo_cache_dir)
repo_url = f"https://github.com/{org}/{repo}"
repo_url_no_token = f"https://github.com/{org}/{repo}"
repo_url_with_token = f"https://{config.GITHUB_TOKEN}@github.com/{org}/{repo}"

repo_url = repo_url_with_token if config.GITHUB_REPO_PRIVATE else repo_url_no_token
# fetch all branches into cache
fetch_cmd = [
"git",
Expand Down
Loading