Skip to content

Commit

Permalink
Try push mirroring to gitlab
Browse files Browse the repository at this point in the history
  • Loading branch information
tcojean committed Jul 20, 2022
1 parent cb2ad2a commit f69df6d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
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
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 }}

0 comments on commit f69df6d

Please sign in to comment.