Files
home-cluster/bootstrap/tasks/validation/github.yaml
T
Oscar RomeuandDevin Buhl 78746180bc feat(ansible): add branch reference as variable in gitrepository (#919)
* feat: add branch reference as variable in gitrepository

* Update bootstrap/vars/config.sample.yaml

---------

Co-authored-by: Devin Buhl <onedr0p@users.noreply.github.com>
2023-08-27 12:10:02 -04:00

43 lines
1.7 KiB
YAML

---
- name: Query Github username
ansible.builtin.uri:
url: https://api.github.com/users/{{ bootstrap_github_username }}
timeout: 5
return_content: true
body_format: json
register: result
- name: Check if username exists
ansible.builtin.assert:
that: result.json.login == bootstrap_github_username
success_msg: Github user {{ bootstrap_github_username }} exists
fail_msg: Github user {{ bootstrap_github_username }} does not exist
- name: Query Github repo
ansible.builtin.uri:
url: https://api.github.com/repos/{{ bootstrap_github_username }}/{{ bootstrap_github_repository_name }}
timeout: 5
return_content: true
body_format: json
register: result
- name: Check if repo exists
ansible.builtin.assert:
that: result.json.full_name == bootstrap_github_username + '/' + bootstrap_github_repository_name
success_msg: Github repo {{ bootstrap_github_username }}/{{ bootstrap_github_repository_name }} exists
fail_msg: Github repo {{ bootstrap_github_username }}/{{ bootstrap_github_repository_name }} does not exist
- name: Query Github repo branch
ansible.builtin.uri:
url: https://api.github.com/repos/{{ bootstrap_github_username }}/{{ bootstrap_github_repository_name }}/branches/{{ bootstrap_github_repository_branch | default('main', true) }}
timeout: 5
return_content: true
body_format: json
register: result
- name: Check if repo branch exists
ansible.builtin.assert:
that: result.json.name == bootstrap_github_repository_branch | default('main', true)
success_msg: Github repo branch {{ bootstrap_github_repository_branch | default('main', true) }} exists
fail_msg: Github repo branch {{ bootstrap_github_repository_branch | default('main', true) }} does not exist