Skip to content

Update .gitlab/.gitlab-ci.yml file #578

Update .gitlab/.gitlab-ci.yml file

Update .gitlab/.gitlab-ci.yml file #578

Workflow file for this run

name: Mirror repo
on:
push:
# Manually triggerable in github
workflow_dispatch:
jobs:
mirror:
runs-on: "ubuntu-latest"
steps:
- name: Configure Private Key
env:
SSH_PRIVATE_KEY: ${{ secrets.DESITNATION_REPO_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "Host *" >> ~/.ssh/config
echo " StrictHostKeyChecking no" >> ~/.ssh/config
echo " CheckHostIP no" >> ~/.ssh/config
echo " LogLevel ERROR" >> ~/.ssh/config
echo " UserKnownHostsFile /dev/null" >> ~/.ssh/config
- name: Push mirror
env:
SOURCE_REPO: "https://github.com/${{ github.repository }}.git"
DESTINATION_REPO: "${{ secrets.DESTINATION_REPO }}"
BASE_REPO: "https://github.com/${{ github.repository }}"
run: |
git clone --quiet "$SOURCE_REPO" && cd `basename "$BASE_REPO"`
git config --global user.name "${{ github.actor }}"
git config --global user.email "bot@example.com"
BRANCH=${{ github.head_ref || github.ref_name }}
EVENT_ACTION=${{ github.event_name }}
if [[ "$branch" == "master" ]] || [[ "$branch" == "developer" ]] || [[ "$EVENT_ACTION" == "workflow_dispatch" ]]
then
FORCE_FLAG="--force"
else
FORCE_FLAG=""
fi
git checkout --quiet $BRANCH
git remote set-url --push origin "$DESTINATION_REPO"
git push $FORCE_FLAG --quiet -u origin $BRANCH