Skip to content

Commit 4c6eb40

Browse files
author
Diepenbruck
committed
add mirroring to github using gitlab-ci.yml
1 parent 7821174 commit 4c6eb40

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

.gitlab-ci.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
stages:
2-
- build
1+
stages: [mirror]
32

4-
build-job:
5-
stage: build
3+
mirror_github_mirror_to_github:
4+
stage: mirror
5+
image: alpine:3.19
6+
rules:
7+
- if: '$CI_COMMIT_BRANCH == "github_mirror"'
8+
before_script:
9+
- apk add --no-cache git
10+
- git config --global user.email "ci@mirror.local"
11+
- git config --global user.name "GitLab CI Mirror"
612
script:
7-
- echo "Compiling the code..."
8-
- echo "Compile complete."
13+
# Create a bare clone of the GitLab repo (fast + good for pushing refs)
14+
- git clone --bare "$CI_REPOSITORY_URL" repo.git
15+
- cd repo.git
16+
17+
# Add GitHub as a remote (PAT auth via env vars)
18+
- git remote add github "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_OWNER}/${GITHUB_REPO}.git"
19+
20+
# Fetch refs from GitLab origin (to ensure we have the latest)
21+
- git fetch origin
22+
23+
# Push ONLY github_mirror -> rag-sphere
24+
# Use --force if you want GitHub to exactly match (history rewrites allowed).
25+
- git push --force github "refs/heads/github_mirror:refs/heads/rag-sphere"

0 commit comments

Comments
 (0)