Skip to content

Commit

Permalink
Merge Push mirroring
Browse files Browse the repository at this point in the history
This adds push mirroring for the current branch.

The way it works is simple, add the GitLab remote, the ssh key, pull the branch from Github then force push to gitlab.

Related PR: #1084
  • Loading branch information
tcojean authored Jul 22, 2022
2 parents 3aba0f7 + e372174 commit 6f0ff7f
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/abidiff.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

pushd old
source .github/bot-pr-base.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/bot-base.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion .github/bot-pr-base.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

source .github/bot-base.sh

Expand Down
2 changes: 1 addition & 1 deletion .github/bot-pr-format-base.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

source .github/bot-pr-base.sh

Expand Down
2 changes: 1 addition & 1 deletion .github/check-format.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

cp .github/bot-pr-format-base.sh /tmp
source /tmp/bot-pr-format-base.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/format-rebase.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

source .github/bot-pr-base.sh

Expand Down
2 changes: 1 addition & 1 deletion .github/format.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

cp .github/bot-pr-format-base.sh /tmp
source /tmp/bot-pr-format-base.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/label.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

source .github/bot-pr-base.sh

Expand Down
22 changes: 22 additions & 0 deletions .github/mirror.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

BRANCH_NAME=${BRANCH_NAME##*/}

git remote add fork "git@github.com:${GITHUB_REPO}.git"
git remote add gitlab "git@gitlab.com:ginkgo-project/ginkgo-public-ci.git"

git remote -v

# Setup ssh
eval $(ssh-agent -s)
echo "${BOT_KEY}" | tr -d '\r' | ssh-add - >/dev/null
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keyscan -t rsa gitlab.com github.com >>~/.ssh/known_hosts

# Fetch from github
git fetch fork "$BRANCH_NAME"
git checkout -B "$BRANCH_NAME"
git reset --hard fork/"$BRANCH_NAME"
# Push to gitlab
git push -u --force gitlab HEAD:$BRANCH_NAME
2 changes: 1 addition & 1 deletion .github/rebase.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

source .github/bot-pr-base.sh

Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Mirroring
on: push

jobs:
to_gitlab:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: develop
persist-credentials: false
- name: Push to Gitlab
run: cp --preserve .github/mirror.sh /tmp && /tmp/mirror.sh
env:
BOT_KEY: ${{ secrets.GITLAB_MIRROR_PRIV_KEY }}
BRANCH_NAME: ${{ github.ref }}
GITHUB_REPO: ${{ github.repository }}

0 comments on commit 6f0ff7f

Please sign in to comment.