-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (41 loc) · 1.53 KB
/
mirror-to-gitverse.yml
File metadata and controls
52 lines (41 loc) · 1.53 KB
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
name: Mirror to GitVerse
on:
push:
branches: ["**"]
tags: ["**"]
delete:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: gitverse-mirror-${{ github.repository }}
cancel-in-progress: false
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- name: Mirror branches + tags to GitVerse
env:
GH_REPO: ${{ github.repository }} # org/repo
GH_TOKEN: ${{ github.token }} # встроенный токен GitHub Actions
GV_TOKEN: ${{ secrets.GH_SYNC }} # <-- ваш секрет (токен GitVerse)
run: |
set -euo pipefail
if [[ -z "${GV_TOKEN:-}" ]]; then
echo "ERROR: missing secret GH_SYNC"
exit 1
fi
SRC="https://x-access-token:${GH_TOKEN}@github.com/${GH_REPO}.git"
DST="https://${GV_TOKEN}@gitverse.ru/${GH_REPO}.git"
git init --bare repo.git
cd repo.git
git remote add origin "$SRC"
# Забираем только ветки и теги (без служебных refs), с прунингом удалений
git fetch --prune --prune-tags origin \
"+refs/heads/*:refs/heads/*" \
"+refs/tags/*:refs/tags/*"
git remote add gitverse "$DST"
# Пушим только ветки и теги, удалённые в GitHub — удаляем и на GitVerse
git push --prune gitverse \
"+refs/heads/*:refs/heads/*" \
"+refs/tags/*:refs/tags/*"