-
-
Notifications
You must be signed in to change notification settings - Fork 5
41 lines (35 loc) · 1.25 KB
/
Copy pathmirror-gitlab.yml
File metadata and controls
41 lines (35 loc) · 1.25 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
name: 🪞 Mirror Repository to GitLab
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: gitlab-mirror
cancel-in-progress: false
jobs:
mirror:
name: Push Mirror to GitLab
runs-on: ubuntu-latest
steps:
- name: Checkout repository (full history)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Push to GitLab
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITLAB_REPO: ${{ secrets.GITLAB_REPO_URL || vars.GITLAB_REPO_URL || 'gitlab.com/Ritual-Dev-Git/dev-shelf.git' }}
run: |
if [ -z "$GITLAB_TOKEN" ]; then
echo "::error::GITLAB_TOKEN secret is missing in GitHub repository secrets!"
exit 1
fi
# Clean repo URL: remove http://, https://, and trailing .git
CLEAN_REPO="${GITLAB_REPO#https://}"
CLEAN_REPO="${CLEAN_REPO#http://}"
CLEAN_REPO="${CLEAN_REPO%.git}"
TARGET_URL="https://oauth2:${GITLAB_TOKEN}@${CLEAN_REPO}.git"
echo "🚀 Mirroring to https://${CLEAN_REPO}.git..."
git push --prune "$TARGET_URL" "+refs/heads/*:refs/heads/*" "+refs/tags/*:refs/tags/*"
echo "✅ Successfully synced all branches and tags to GitLab!"