Skip to content

Commit

Permalink
Add support for specifying Git ref on required repositories (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsee authored Jul 1, 2020
1 parent 01020d0 commit e0e9fff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ repositories:
ssh_private_key: /my/path/to/an/ssh/key
- name: automation-repo-2
url: https://github.com/my-org/some-ansible-playbooks-2.git
ref: integration
```
Both `ref` and `secret.ssh_private_key` are optional, to be used when a Git ref other than `master` is desired, or an SSH pull secret is required, respectively.

Upon application startup, these repositories are cloned. They can be referenced from that point forward by their name as defined here, _not_ by any part of their Git URL.

**The same scheduling mechanism used to trigger tasks is _automatically configured_ to pull new changes from these repositories every two minutes, so updates to these dependencies should be picked up _without any user intervention required_.**
3 changes: 2 additions & 1 deletion resource-dispatcher/repositories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def configure_repository(repository):

if not os.path.exists(repo_directory):
os.makedirs(repo_directory)
ref = repository["ref"] if "ref" in repository else "master"
print(f"Cloning {repository['url']}...")
repo = Repo.clone_from(repository["url"], repo_directory, branch="master", env=env)
repo = Repo.clone_from(repository["url"], repo_directory, branch=ref, env=env)
print(f"Cloned {repository['url']}")
else:
repo = Repo.init(repo_directory)
Expand Down

0 comments on commit e0e9fff

Please sign in to comment.