Skip to content

Commit

Permalink
chore: add GitHub Actions workflow for syncing with GitLab
Browse files Browse the repository at this point in the history
  • Loading branch information
iamvikshan committed Nov 18, 2024
1 parent 64621f3 commit 07771a6
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/git-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Sync Repositories

on:
# Trigger on pushes to all branches
push:
branches:
- '**'
# Trigger on pull request events
pull_request:
types: [opened, closed]
# Allow manual trigger
workflow_dispatch:
# Run on a schedule (every 6 hours) to catch GitLab changes
schedule:
- cron: '0 */6 * * *'

jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout GitHub repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "vixshan"
git config user.email "[email protected]"
- name: Add GitLab remote
run: |
git remote add gitlab https://oauth2:${GITLAB_TOKEN}@gitlab.com/vikshan/amina.git
- name: Fetch and sync with GitLab
run: |
# Fetch all branches and tags from GitLab
git fetch gitlab
# Push all GitHub branches to GitLab
git push -f gitlab refs/remotes/origin/*:refs/heads/*
# Push all tags to GitLab
git push -f gitlab --tags
# Pull changes from GitLab and push to GitHub
git pull gitlab --allow-unrelated-histories || true
git push origin --all
git push origin --tags
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}

0 comments on commit 07771a6

Please sign in to comment.