From 22b0388b04a350153517835d45a303b624578ae8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 20 Dec 2025 01:51:22 +0000 Subject: [PATCH] Add GitHub workflow to mirror branches to GitLab This workflow automatically mirrors all branches (except main/master) to GitLab when pushed to GitHub. It uses a GitLab token for authentication and supports configurable GitLab URL and repository via GitHub variables. --- .github/workflows/mirror-to-gitlab.yml | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/mirror-to-gitlab.yml diff --git a/.github/workflows/mirror-to-gitlab.yml b/.github/workflows/mirror-to-gitlab.yml new file mode 100644 index 0000000..dfb57e3 --- /dev/null +++ b/.github/workflows/mirror-to-gitlab.yml @@ -0,0 +1,37 @@ +name: Mirror to GitLab + +on: + push: + branches: + - '**' + - '!main' + - '!master' + +jobs: + mirror: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Mirror to GitLab + env: + GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} + GITLAB_URL: ${{ vars.GITLAB_URL || 'https://gitlab.com' }} + GITLAB_REPO: ${{ vars.GITLAB_REPO || 'postgres-ai/docs' }} + run: | + # Configure git + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "GitHub Actions" + + # Add GitLab remote with token auth + git remote add gitlab "https://oauth2:${GITLAB_TOKEN}@${GITLAB_URL#https://}/${GITLAB_REPO}.git" + + # Push the current branch + BRANCH_NAME="${GITHUB_REF#refs/heads/}" + echo "Pushing branch: ${BRANCH_NAME}" + git push gitlab "HEAD:refs/heads/${BRANCH_NAME}" --force + + echo "Successfully mirrored to GitLab"