-
Notifications
You must be signed in to change notification settings - Fork 11
51 lines (42 loc) · 1.69 KB
/
sync-github-to-gitlab.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
name: Sync GitHub to GitLab
on:
push:
branches:
- main
jobs:
sync:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout GitHub repository with full history
- name: Checkout GitHub Repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch full history for context
# Step 2: Configure Git identity
- name: Configure Git Identity
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "kelumalai@presidio.com"
# Step 3: Setup SSH for GitLab
- name: Setup SSH for GitLab
run: |
mkdir -p ~/.ssh
echo "${{ secrets.GITLAB_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H gitlab.presidio.com >> ~/.ssh/known_hosts
# Step 4: Add GitLab remote
- name: Add GitLab remote
run: git remote add gitlab git@gitlab.presidio.com:hai-build/specif-ai-github.git
# Step 5: Fetch GitLab release/QA branch
- name: Fetch GitLab release/QA branch
run: git fetch gitlab release/QA || true # Ensure GitLab release/QA branch is fetched
# Step 6: Checkout GitLab release/QA branch
- name: Checkout GitLab release/QA branch
run: |
git checkout release/QA || git checkout -b release/QA gitlab/release/QA
# Step 7: Merge GitHub main into GitLab release/QA
- name: Merge GitHub main into GitLab release/QA
run: git merge origin/main --allow-unrelated-histories --strategy-option=theirs || true
# Step 8: Push only to GitLab release/QA
- name: Push Final Changes to GitLab release/QA branch
run: git push gitlab release/QA