Skip to content

Commit 034d7c9

Browse files
committed
sync gitlab
1 parent a93617e commit 034d7c9

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 'Git Repo Sync'
2+
description: 'Git Repo Sync enables you to synchronize code to other code management platforms, such as GitLab, Gitee, etc.'
3+
4+
branding:
5+
icon: upload-cloud
6+
color: gray-dark
7+
8+
inputs:
9+
target-url:
10+
description: 'Target Repo URL'
11+
required: true
12+
target-username:
13+
description: 'Target Repo Username'
14+
required: true
15+
target-token:
16+
description: 'Target Token'
17+
required: true
18+
runs:
19+
using: "composite"
20+
steps:
21+
- run: ${{ github.action_path }}/entrypoint.sh
22+
shell: bash
23+
env:
24+
INPUT_TARGET_URL: ${{ inputs.target-url }}
25+
INPUT_TARGET_USERNAME: ${{ inputs.target-username }}
26+
INPUT_TARGET_TOKEN: ${{ inputs.target-token }}
27+
GITHUB_EVENT_REF: ${{ github.event.ref }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
git remote add target https://${INPUT_TARGET_USERNAME}:${INPUT_TARGET_TOKEN}@${INPUT_TARGET_URL#https://}
2+
3+
case "${GITHUB_EVENT_NAME}" in
4+
push)
5+
git push -f --all target
6+
git push -f --tags target
7+
;;
8+
delete)
9+
git push -d target ${GITHUB_EVENT_REF}
10+
;;
11+
*)
12+
break
13+
;;
14+
esac

.github/workflows/git-repo-sync.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: GitlabSync
2+
3+
on:
4+
- push
5+
- delete
6+
7+
jobs:
8+
sync:
9+
runs-on: ubuntu-latest
10+
name: Git Repo Sync
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
- uses: ./.github/actions/git-repo-sync
16+
with:
17+
target-url: ${{ secrets.TARGET_URL }}
18+
target-username: ${{ secrets.TARGET_USERNAME }}
19+
target-token: ${{ secrets.TARGET_TOKEN }}

0 commit comments

Comments
 (0)