Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push mirroring #1084

Merged
merged 5 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
23 changes: 23 additions & 0 deletions .github/mirror.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/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
git config user.email "ginkgo.library@gmail.com"
git config user.name "Ginkgo Bot"

# Fetch from github
git fetch fork "$BRANCH_NAME"
git checkout -b fork/$BRANCH_NAME
# Push to gitlab
git push --force --prune gitlab $BRANCH_NAME
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to use HEAD:$BRANCH_NAME or fork/$BRACNH_NAME:$BRANCH_NAME
otherwise, I get "error: src refspec test does not match any."

Copy link
Member

@yhmtsai yhmtsai Jul 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git checkout -b fork/$BRANCH_NAME only creates the branch on the current folder, so it does not switch to the branch from fork
need to use git checkout -b fork/$BRANCH_NAME fork/$BRANCH_NAME

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems not to delete the unexisting branch?

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
19 changes: 19 additions & 0 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Mirroring
on: push

jobs:
to_gitlab:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: develop
fetch-depth: 0
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 }}