denkMinds


Achievement : โœจ Sync GitHub Commits to GitLab Without a Subscription

A Step-by-Step Guide : Recently, we successfully created a GitHub Action that allows seamless synchronization of every commit from a GitHub repository to GitLab. This workflow eliminates the need for a GitLab subscription to use CI/CD features or automate the synchronization process. Here's a detailed guide on how we achieved it.


Step 1: ๐Ÿ—‚๏ธ Prepare GitHub and GitLab Repositories

Achievement Achievement

Step 2: ๐Ÿ”‘ Generate a GitLab Personal Access Token (PAT)

  1. Navigate to your GitLab account.
  2. Go to Settings > Access Tokens.
  3. Create a new token with the required scopes:
    • api
    • write_repository
  4. Save/copy the generated token securely.
Achievement Achievement

Step 3: ๐Ÿ”’ Store the PAT in GitHub Secrets

  1. In your GitHub repository, navigate to Settings > Secrets and variables > Actions.
  2. Click New repository secret.
  3. Add a secret with:
    • Name: GITLAB_TOKEN
    • Value: The GitLab PAT generated/saved earlier.
Achievement Achievement Achievement

Step 4: โš™๏ธ Configure the GitHub Actions Workflow

  1. Create a .github/workflows/sync-to-gitlab.yml file in your GitHub repository.
  2. Add the following workflow code:
Achievement
  1. Replace <your-gitlab-username> and <your-gitlab-repo-name> with your GitLab details.

Step 5: ๐Ÿงช Test the Workflow

  1. Push a commit to the main branch in your GitHub repository.
  2. Verify that the changes are automatically reflected in your GitLab repository.
Achievement

Reflected from github to gitlab

Achievement

Conclusion ๐Ÿ”š

By following these steps, you can effortlessly sync commits from GitHub to GitLab without requiring additional subscriptions or manual intervention. This process leverages GitHub Actions and a simple GitLab PAT for authentication, providing an efficient and cost-effective solution.

denkMinds

Imprint

ยฉ 2025 denkMinds. All rights reserved.

DISCLAIMER: This website does not belong to a real company. It is a Planspiel Web Engineering project.