Skip to content

Commit a893a55

Browse files
Merge pull request #6 from Kaveri-Jeevanantham/feature/github-gitlab-pipeline-setup
feat(ci): Add GitHub to GitLab sync workflow.
2 parents 23f10d2 + 28aec33 commit a893a55

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Sync GitHub to GitLab
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
sync:
8+
runs-on: ubuntu-latest
9+
steps:
10+
# Step 1: Checkout GitHub repository with full history
11+
- name: Checkout GitHub Repository
12+
uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0 # Fetch the full history to ensure full context
15+
# Step 2: Configure Git identity
16+
- name: Configure Git Identity
17+
run: |
18+
git config --global user.name "GitHub Actions Bot"
19+
git config --global user.email "kelumalai@presidio.com"
20+
# Step 3: Setup SSH for GitLab
21+
- name: Setup SSH for GitLab
22+
run: |
23+
mkdir -p ~/.ssh
24+
echo "${{ secrets.GITLAB_SSH_KEY }}" > ~/.ssh/id_rsa
25+
chmod 600 ~/.ssh/id_rsa
26+
ssh-keyscan -H gitlab.presidio.com >> ~/.ssh/known_hosts
27+
# Step 4: Add GitLab remote
28+
- name: Add GitLab remote
29+
run: git remote add gitlab git@gitlab.presidio.com:hai-build/specif-ai-github.git
30+
# Step 5: Fetch GitLab branch
31+
- name: Fetch GitLab branch
32+
run: git fetch gitlab main || true # Ensure GitLab branch is fetched
33+
# Step 6: Reconcile Divergent Histories
34+
- name: Reconcile Divergent Histories
35+
run: |
36+
# Checkout the current branch
37+
git checkout main
38+
39+
# Merge GitLab branch into GitHub branch, allowing unrelated histories
40+
git merge gitlab/main --allow-unrelated-histories --strategy-option=theirs || true
41+
# Force push to GitLab if necessary
42+
git push gitlab main || git push --force gitlab main
43+
# Step 7: Push Final Changes
44+
- name: Push Final Changes
45+
run: git push gitlab main

0 commit comments

Comments
 (0)