-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (115 loc) · 5.22 KB
/
mirror.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: 'Mirror'
on:
- push
env:
OWNER: '${{ github.repository_owner }}'
USER_AGENT: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0'
jobs:
# ------------------------------------------------------------------------------------------------------------------ #
# GITLAB
# ------------------------------------------------------------------------------------------------------------------ #
mirror_gitlab:
runs-on: ubuntu-latest
name: 'GitLab'
env:
DOMAIN: 'https://gitlab.com'
VERSION: 'v4'
NSID: '69852292'
steps:
- name: 'Get repository name'
shell: bash
run: |
echo "REPO_NAME=$( echo '${{ github.repository }}' | awk -F '/' '{ print $2 }' )" >> $GITHUB_ENV
- name: 'Create repository'
shell: bash
run: |
http="$( curl -s -o '/dev/null' -I -w '%{http_code}' -A '${{ env.USER_AGENT }}' '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}' )"
if [[ "${http}" -ne 200 ]]; then
curl -X POST \
-H 'Authorization: Bearer ${{ secrets.BOT_MIRROR_TOKEN_GITLAB }}' \
-H 'Content-Type: application/json' \
-A '${{ env.USER_AGENT }}' \
'${{ env.DOMAIN }}/api/${{ env.VERSION }}/projects/' \
-d '{"name":"${{ env.REPO_NAME }}","path":"${{ env.REPO_NAME }}","namespace_id":"${{ env.NSID }}","visibility":"public"}'
fi
- name: 'Mirror repository'
uses: ghastore/github-mirror@main
with:
src_repo: '${{ github.server_url }}/${{ github.repository }}.git'
src_user: '${{ secrets.BOT_MIRROR_NAME }}'
src_token: '${{ secrets.BOT_MIRROR_TOKEN_GITHUB }}'
dst_repo: '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}.git'
dst_user: '${{ secrets.BOT_MIRROR_NAME }}'
dst_token: '${{ secrets.BOT_MIRROR_TOKEN_GITLAB }}'
# ------------------------------------------------------------------------------------------------------------------ #
# CODEBERG
# ------------------------------------------------------------------------------------------------------------------ #
mirror_codeberg:
runs-on: ubuntu-latest
name: 'Codeberg'
env:
DOMAIN: 'https://codeberg.org'
VERSION: 'v1'
steps:
- name: 'Get repository name'
shell: bash
run: |
echo "REPO_NAME=$( echo '${{ github.repository }}' | awk -F '/' '{ print $2 }' )" >> $GITHUB_ENV
- name: 'Create repository'
shell: bash
run: |
http="$( curl -s -o '/dev/null' -I -w '%{http_code}' -A '${{ env.USER_AGENT }}' '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}' )"
if [[ "${http}" -ne 200 ]]; then
curl -X POST \
-H 'Authorization: token ${{ secrets.BOT_MIRROR_TOKEN_CODEBERG }}' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-A '${{ env.USER_AGENT }}' \
'${{ env.DOMAIN }}/api/${{ env.VERSION }}/orgs/${{ env.OWNER }}/repos' \
-d '{"name":"${{ env.REPO_NAME }}"}'
fi
- name: 'Mirror repository'
uses: ghastore/github-mirror@main
with:
src_repo: '${{ github.server_url }}/${{ github.repository }}.git'
src_user: '${{ secrets.BOT_MIRROR_NAME }}'
src_token: '${{ secrets.BOT_MIRROR_TOKEN_GITHUB }}'
dst_repo: '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}.git'
dst_user: '${{ secrets.BOT_MIRROR_NAME }}'
dst_token: '${{ secrets.BOT_MIRROR_TOKEN_CODEBERG }}'
# ------------------------------------------------------------------------------------------------------------------ #
# DISROOT
# ------------------------------------------------------------------------------------------------------------------ #
mirror_disroot:
runs-on: ubuntu-latest
name: 'Disroot'
env:
DOMAIN: 'https://git.disroot.org'
VERSION: 'v1'
steps:
- name: 'Get repository name'
shell: bash
run: |
echo "REPO_NAME=$( echo '${{ github.repository }}' | awk -F '/' '{ print $2 }' )" >> $GITHUB_ENV
- name: 'Create repository'
shell: bash
run: |
http="$( curl -s -o '/dev/null' -I -w '%{http_code}' -A '${{ env.USER_AGENT }}' '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}' )"
if [[ "${http}" -ne 200 ]]; then
curl -X POST \
-H 'Authorization: token ${{ secrets.BOT_MIRROR_TOKEN_DISROOT }}' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-A '${{ env.USER_AGENT }}' \
'${{ env.DOMAIN }}/api/${{ env.VERSION }}/orgs/${{ env.OWNER }}/repos' \
-d '{"name":"${{ env.REPO_NAME }}"}'
fi
- name: 'Mirror repository'
uses: ghastore/github-mirror@main
with:
src_repo: '${{ github.server_url }}/${{ github.repository }}.git'
src_user: '${{ secrets.BOT_MIRROR_NAME }}'
src_token: '${{ secrets.BOT_MIRROR_TOKEN_GITHUB }}'
dst_repo: '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}.git'
dst_user: '${{ secrets.BOT_MIRROR_NAME }}'
dst_token: '${{ secrets.BOT_MIRROR_TOKEN_DISROOT }}'