-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitlab-import.yml
executable file
·45 lines (40 loc) · 1.11 KB
/
gitlab-import.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env ansible-playbook
---
- name: Import repository into gitlab project
hosts: localhost
become: false
gather_facts: false
vars:
github_owner: buluma
gitlab_namespace: shadowwalker
vars_files:
- defaults/main.yml
- vars/main.yml
- vars/vault.yml
tasks:
- name: see if all variables are set
assert:
that:
- gitlab_namespace is defined
- github_owner is defined
- role is defined
quiet: true
- name: Get GitHub repo information
uri:
url: "https://api.github.com/repos/{{ github_owner }}/{{ role }}"
headers:
Authorization: "Bearer {{ github_token }}"
register: github_repo
- name: Import repository
uri:
url: "https://gitlab.com/api/v4/import/github"
method: POST
headers:
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
body_format: json
body:
personal_access_token: "{{ github_token }}"
repo_id: "{{ github_repo.json.id }}"
target_namespace: "{{ gitlab_namespace }}"
status_code:
- 201