blob: 236b28c975c9c9a06214c7ea0085027474501eb0 (
plain)
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
|
# source repo .gitlab-ci.yml
# requires a project access token (Project > Settings > Access tokens):
# - TOKEN with read_repository, write_repository; Role: Maintainer
#
# disable protected branch for Maintainer (Project > Settings > Repository):
# - main branch allowed to merge, allowed to push and merge maintainer; allowed to force push on
#
# requires the following gitlab variables (Project > Settings > CI/CD > Variables):
# - REPO_NAME: gitlab.com/<user>/<repo_name> (Protected, Masked, Expanded)
# - SOURCE_REPO: https://cgit.example.com/<repo_name> (Protected, Masked, Expanded)
# - TOKEN: <project access token> (Protected, Masked, Expanded)
#
stages:
- mirror
mirror-from-cgit:
stage: mirror
image: ubuntu:20.04
before_script:
- apt-get update -y && apt-get install -y git
- git config --global user.name "CI"
- git config --global user.email "ci@gitlab.com"
script:
- git clone --mirror "$SOURCE_REPO" temp_repo
- cd temp_repo
- TARGET_REPO="https://oauth2:$TOKEN@$REPO_NAME"
- git remote set-url origin "$TARGET_REPO"
- git push --prune --mirror
only:
- schedules
|