@opensaucedhub/git-sync-action
v1.1.4
Published
Synchronize GitHub repository with GitLab including branches, PRs, and issues
Downloads
376
Maintainers
Readme
GitHub GitLab Sync Action
A powerful GitHub Action that provides bi-directional synchronization between GitHub and GitLab repositories. This action helps maintain consistency across platforms by syncing branches, pull requests, issues, releases, and tags.
Features
- 🔄 Bi-directional Synchronization: Sync from GitHub to GitLab and vice versa
- 🌳 Branch Synchronization: Keep branches in sync across platforms
- 🔀 Pull Request/Merge Request Sync: Synchronize pull requests with corresponding merge requests
- 📝 Issue Tracking: Keep issues and their comments in sync
- 🏷️ Release Management: Sync releases and tags across platforms
- ⚙️ Configurable: Extensive configuration options for fine-grained control
- 🔒 Protected Resources: Support for protected branches and resources
- 🏷️ Label Management: Automatic labeling of synced resources
Setup
- Create a
.github/workflows/sync.yml
file in your repository:
name: Sync to GitLab
on:
push:
branches: [main]
pull_request:
types: [opened, closed, reopened]
issues:
types: [opened, closed, reopened]
release:
types: [published]
schedule:
- cron: '0 */6 * * *'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sync with GitLab
uses: OpenSaucedHub/[email protected]
with:
CONFIG_PATH: .github/sync-config.yml # optional, defaults to .github/sync-config.yml
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} # optional, unless you want to sync to GitLab
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} # Optional, defaults to GITHUB_TOKEN
- Create a
.github/sync-config.yml
file with your sync configuration:
#sync-config.yml
# When you have gitlab.sync.[entity].enabled: true, it means those entities will be synced FROM GitHub TO GitLab
gitlab:
enabled: true
username: # Optional, defaults to GitHub repo owner
# When you have github.sync.[entity].enabled: true, it means those entities will be synced FROM GitLab TO GitHub
github:
enabled: true
[!WARNING]
- If no config is provided, everything defaults to
true
,autoMerge
isfalse
,Labels
are set as specified in the default config andrepo
name andusername
default to GitHub repositoryowner/repo
. See Accepted Configuration- In case of a partial config (missing fields), the defaults are used. (you MUST strictly set elements to false if you don't want them to sync). See Accepted Configuration
- Set up required secrets in your GitHub repository:
GITLAB_TOKEN
: A GitLab personal access token with API accessGH_TOKEN
: A GitHub personal access token (optional, defaults toGITHUB_TOKEN
)
Accepted Configuration
#sync-config.yml
# When you have gitlab.sync.[entity].enabled: true, it means those entities will be synced FROM GitHub TO GitLab
gitlab:
enabled: true
url: 'gitlab.com' # Optional, defaults to gitlab.com
username: # Optional, defaults to GitHub repo owner
repo: # Optional, defaults to GitHub repo name
sync:
branches:
enabled: true
protected: true
pattern: '*'
pullRequests:
enabled: true
autoMerge: false
labels: ['synced-from-github']
issues:
enabled: true
syncComments: true
labels: ['synced-from-github']
releases:
enabled: true
tags:
enabled: true # automatically enabled if releases = true
# When you have github.sync.[entity].enabled: true, it means those entities will be synced FROM GitLab TO GitHub
github:
enabled: true
username: # Optional, defaults to GitHub username
repo: # Optional, defaults to GitHub repo name
sync:
branches:
enabled: true
protected: true
pattern: '*'
pullRequests:
enabled: true
autoMerge: false
labels: ['synced-from-gitlab']
issues:
enabled: true
syncComments: true
labels: ['synced-from-gitlab']
releases:
enabled: true
tags:
enabled: true # automatically enabled if releases = true
Configuration Options
GitLab Configuration (gitlab
)
| Option | Description | Required | Default |
| ---------- | ----------------------------- | -------- | ----------------- |
| enabled
| Enable GitLab synchronization | No | true |
| url
| GitLab instance URL | No | gitlab.com |
| username
| GitLab username | No | GitHub repo owner |
| repo
| GitLab repository name | No | GitHub repo name |
GitHub Configuration (github
)
| Option | Description | Required | Default |
| ---------- | ----------------------------- | -------- | -------------- |
| enabled
| Enable GitHub synchronization | No | true |
| username
| GitHub username | No | GitHub context |
| repo
| GitHub repository name | No | GitHub context |
Sync Configuration
Branches
| Option | Description | Required | Default |
| ----------- | ----------------------- | -------- | ------- |
| enabled
| Enable branch sync | No | true |
| protected
| Sync protected branches | No | true |
| pattern
| Branch name pattern | No | "*" |
Pull Requests
| Option | Description | Required | Default |
| ----------- | --------------------------- | -------- | ------------------------- |
| enabled
| Enable PR sync | No | true |
| autoMerge
| Auto-merge synced PRs | No | false |
| labels
| Labels to add to synced PRs | No | synced-from-github/gitlab |
Issues
| Option | Description | Required | Default |
| -------------- | ------------------------------ | -------- | ------------------------- |
| enabled
| Enable issue sync | No | true |
| syncComments
| Sync issue comments | No | false |
| labels
| Labels to add to synced issues | No | synced-from-github/gitlab |
Releases and Tags
| Option | Description | Required | Default |
| --------- | ----------------------- | -------- | ------- |
| enabled
| Enable release/tag sync | No | true |
Token Permissions
GitLab Token
The GitLab token needs the following permissions:
api
- Full API accessread_repository
- Read repositorywrite_repository
- Write repository
GitHub Token
The GitHub token needs the following permissions:
repo
- Full repository accessworkflow
- Workflow access
Contributing 🤝
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
License 📄
This project is licensed under the MIT License - see the LICENSE file for details.
Security 🔐
- The action uses token-based authentication for secure operations
- Tokens are never exposed in logs or outputs
- Protected branch settings are respected
- All API calls use HTTPS
Support 💬
For support, please:
- Check the Issues page
- Create a new issue if your problem isn't already listed
- Provide as much context as possible
Acknowledgments 🙏
- Inspired by Sync to GitLab action, just felt awful having to sync PRs/MRs, branches, releases and issues manually.
- Built with TypeScript and Bun
- Uses the official GitLab API and GitHub Actions toolkit