Add GitLab mirroring pipeline #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Mirror to GitLab | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- '**' | |
jobs: | |
mirror: | |
runs-on: self-hosted | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Push to GitLab | |
run: | | |
for branch in $(git branch -r | grep -v '\->'); do | |
branch_name=${branch#origin/} | |
echo "Processing branch: $branch_name" | |
if git show-ref --verify --quiet refs/heads/$branch_name; then | |
echo "Branch '$branch_name' already exists, checking out..." | |
git checkout $branch_name | |
else | |
git checkout -b $branch_name $branch | |
fi | |
git remote add gitlab https://gdb:${{ secrets.GITLAB_TOKEN }}@liis-it.gitlab.yandexcloud.net/archive/mobile/simple-react-native.git | |
git push -u gitlab $branch_name | |
git remote remove gitlab | |
git checkout gitlab/mirror | |
done |