-
Notifications
You must be signed in to change notification settings - Fork 170
35 lines (34 loc) · 1.6 KB
/
sync_remote.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
on: [push, delete]
jobs:
push:
runs-on: ubuntu-latest
if: github.repository == 'ibhagwan/fzf-lua'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sync remote repositories
run: |
mkdir -p ~/.ssh
echo "${{ secrets.GIT_SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
# Ignore hosts keys, since we accept them as-is
git config --global core.sshCommand 'ssh -i ~/.ssh/id_rsa -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
# Codeberg
git remote add codeberg ssh://[email protected]/ibhagwan/fzf-lua.git
git push --tags --force --prune codeberg 'refs/remotes/origin/*:refs/heads/*'
# GitLab
# NOTE: pushing refs fails with:
# remote: GitLab: You cannot create a branch with an invalid name.
# To ssh://gitlab.com/ibhagwan/fzf-lua.git
# ! [remote rejected] origin/HEAD -> HEAD (pre-receive hook declined)
# ! [remote rejected] origin/dev -> dev (pre-receive hook declined)
git remote add gitlab ssh://[email protected]/ibhagwan/fzf-lua.git
# NOTE: `--all` syncs local branches only
# create tracking braches for all remote branches
for branch in $(git branch --all | grep '^\s*remotes' | grep -vP 'HEAD'); do
git rev-parse --verify "${branch##*/}" 1>/dev/null 2>&1 || \
git branch --track "${branch##*/}" "$branch"
done
git push --force --prune gitlab --all
git push --force gitlab --tags