-
-
Notifications
You must be signed in to change notification settings - Fork 28
51 lines (43 loc) · 1.44 KB
/
mirror.yml
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# REF: https://github.com/JamesRobionyRogers/GitHub-to-GitBucket-Action/blob/47a44e9/.github/workflows/push-to-gitbucket.yml
name: Mirror Repository
on:
workflow_dispatch:
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Fetch all branches
run: |
git fetch --all
git fetch --tags
- name: List branches
run: |
git branch -a
# Enables tracking of remote branches ensuring all branches are pushed to mirror repo
- name: Track remote branches
run: |
for branch in $(git branch -r | grep -v '\->'); do
local_branch=${branch#origin/}
git branch --track "$local_branch" "$branch" || true
done
- name: Push to mirror repo (GitLab)
env:
MIRROR_URL: "gitlab.com/null2264/yokai.git"
MIRROR_USERNAME: ${{ secrets.MIRROR_USERNAME }}
MIRROR_AUTH: ${{ secrets.MIRROR_AUTH }}
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git remote add mirror https://$MIRROR_USERNAME:$MIRROR_AUTH@$MIRROR_URL
git push --mirror -v mirror || true