-
Notifications
You must be signed in to change notification settings - Fork 10
64 lines (57 loc) · 2.16 KB
/
github-to-gitlab.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: GitHub to GitLab
on:
workflow_dispatch:
schedule:
- cron: "0 2 * * 3"
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# https://github.com/actions/setup-python
- uses: actions/setup-python@v2
with:
python-version: "3.6.8"
- name: Unprotect branches
run: |
python -V
pip -V
pip install requests
python unprotect_branches.py k8scat ${{ secrets.DEST_TOKEN_GITLAB }}
- name: Login Source GitHub
run: |
gh --version
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
gh auth status
- name: List repos
id: list_repos
run: |
repo_list=$(gh repo list -L 1000 --json name -t '{{range $i, $n := .}}{{if (gt $i 0)}},{{end}}{{$n.name}}{{end}}')
echo "::set-output name=repo_list::${repo_list}"
- name: GitHub to GitLab
uses: k8scat/action-mirror-git@v0.1.3
with:
source_protocol: https
source_host: github.com
source_username: k8scat
source_token: ${{ secrets.GITHUB_TOKEN }}
dest_protocol: https
dest_host: gitlab.com
dest_username: k8scat
dest_token: ${{ secrets.DEST_TOKEN_GITLAB }}
mirror_repos: ${{ steps.list_repos.outputs.repo_list }}
lark_webhook: ${{ secrets.LARK_WEBHOOK }}
notify_prefix: "GitHub to GitLab"
ignore_error: "true"
dest_create_repo_script: |
# load functions: gitlab_update_project, gitlab_create_project, urlencode
source /mirror-git/functions/url.sh
source /mirror-git/functions/gitlab.sh
result=$(gitlab_update_project ${INPUT_DEST_TOKEN} $(urlencode ${INPUT_DEST_USERNAME}/${REPO_NAME}) "{\"lfs_enabled\":false}")
if [[ "${result}" = "404" ]]; then
result=$(gitlab_create_project ${INPUT_DEST_TOKEN} "{\"name\":\"${REPO_NAME}\",\"lfs_enabled\":false}")
if [[ "${result}" != "201" ]]; then
notify "Failed to create gitlab project: ${REPO_NAME}"
exit 1
fi
fi