Repository navigation
54 lines (48 loc) · 1.88 KB
/
Copy pathmirror.yaml
File metadata and controls
54 lines (48 loc) · 1.88 KB
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
52
53
54
name: 🪞 Mirror to GitLab, Bitbucket & Codeberg
# GitHub is the source of truth: every branch and tag is force-pushed to the
# mirrors. Anything committed directly on GitLab/Bitbucket/Codeberg gets
# overwritten, so merge contributions coming from there through GitHub.
# Triggered manually from the Actions tab (or `gh workflow run mirror.yaml`).
on:
workflow_dispatch:
# Queue runs instead of running them in parallel so pushes never race
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
jobs:
mirror:
# Prevents the workflow from running on forks
if: ${{ github.repository_owner == 'aymericzip' }}
name: 🪞 Mirror to ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: GitLab
url: https://oauth2:MIRROR_TOKEN@gitlab.com/ay.pineau/intlayer.git
secret: GITLAB_TOKEN
- name: Bitbucket
url: https://x-token-auth:MIRROR_TOKEN@bitbucket.org/intlayer/intlayer.git
secret: BITBUCKET_TOKEN
- name: Codeberg
url: https://aymericzip:MIRROR_TOKEN@codeberg.org/aymericzip/intlayer.git
secret: CODEBERG_TOKEN
steps:
- name: ⬇️ Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: 🚀 Push branches and tags
env:
MIRROR_TOKEN: ${{ secrets[matrix.secret] }}
MIRROR_URL: ${{ matrix.url }}
run: |
git remote add mirror "${MIRROR_URL/MIRROR_TOKEN/$MIRROR_TOKEN}"
# refs/remotes/origin/* holds every GitHub branch (checkout only
# creates one local branch, so `git push --all` would miss them)
git push --force mirror \
'refs/remotes/origin/*:refs/heads/*' \
'^refs/remotes/origin/HEAD' \
'refs/tags/*:refs/tags/*'