Skip to content

Instantly share code, notes, and snippets.

@guilbep
Last active April 15, 2025 09:29
Show Gist options
  • Save guilbep/fb40c3866ea1b6ff5609bf4854b1f39a to your computer and use it in GitHub Desktop.
Save guilbep/fb40c3866ea1b6ff5609bf4854b1f39a to your computer and use it in GitHub Desktop.
automatic push to gitlab
name: Mirror to GitLab
on:
push:
branches:
- '**' # Trigger on push to any branch
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history for mirroring
- name: Push to GitLab mirror
env:
GITLAB_USERNAME: ${{ secrets.GITLAB_USERNAME }}
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITLAB_URL: ${{ secrets.GITLAB_URL }} # e.g., 'gitlab.com' or your self-hosted GitLab URL
GITHUB_REPOSITORY: ${{ github.repository }}
run: |
echo "Setting up GitLab remote..."
git remote add gitlab https://${GITLAB_USERNAME}:${GITLAB_TOKEN}@${GITLAB_URL}/${GITHUB_REPOSITORY}.git
echo "Pushing to GitLab mirror..."
git push gitlab --mirror --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment