Skip to content

Commit 769d20a

Browse files
committed
Update mirror workflow with workflow_dispatch and dynamic repo name
1 parent 81dd567 commit 769d20a

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/mirror.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Mirror to GitLab and Bitbucket
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
tags:
7+
- 'v*'
8+
workflow_dispatch:
9+
10+
jobs:
11+
mirror-gitlab:
12+
runs-on: ubuntu-latest
13+
if: ${{ vars.GITLAB_MIRROR_ENABLED == 'true' }}
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Push to GitLab
22+
env:
23+
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
24+
REPO_NAME: ${{ github.event.repository.name }}
25+
run: |
26+
git remote add gitlab https://oauth2:${GITLAB_TOKEN}@gitlab.com/hyperpolymath/${REPO_NAME}.git || true
27+
git push gitlab HEAD:main --force || git push gitlab HEAD:master --force
28+
git push gitlab --tags --force
29+
30+
mirror-bitbucket:
31+
runs-on: ubuntu-latest
32+
if: ${{ vars.BITBUCKET_MIRROR_ENABLED == 'true' }}
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
with:
38+
fetch-depth: 0
39+
40+
- name: Push to Bitbucket
41+
env:
42+
BITBUCKET_TOKEN: ${{ secrets.BITBUCKET_TOKEN }}
43+
REPO_NAME: ${{ github.event.repository.name }}
44+
run: |
45+
git remote add bitbucket https://x-token-auth:${BITBUCKET_TOKEN}@bitbucket.org/hyperpolymath/${REPO_NAME}.git || true
46+
git push bitbucket HEAD:main --force || git push bitbucket HEAD:master --force
47+
git push bitbucket --tags --force

0 commit comments

Comments
 (0)