Skip to content

Commit

Permalink
sync gitlab
Browse files Browse the repository at this point in the history
  • Loading branch information
khergalant committed Feb 13, 2024
1 parent a93617e commit 034d7c9
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/actions/git-repo-sync/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Git Repo Sync'
description: 'Git Repo Sync enables you to synchronize code to other code management platforms, such as GitLab, Gitee, etc.'

branding:
icon: upload-cloud
color: gray-dark

inputs:
target-url:
description: 'Target Repo URL'
required: true
target-username:
description: 'Target Repo Username'
required: true
target-token:
description: 'Target Token'
required: true
runs:
using: "composite"
steps:
- run: ${{ github.action_path }}/entrypoint.sh
shell: bash
env:
INPUT_TARGET_URL: ${{ inputs.target-url }}
INPUT_TARGET_USERNAME: ${{ inputs.target-username }}
INPUT_TARGET_TOKEN: ${{ inputs.target-token }}
GITHUB_EVENT_REF: ${{ github.event.ref }}
14 changes: 14 additions & 0 deletions .github/actions/git-repo-sync/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
git remote add target https://${INPUT_TARGET_USERNAME}:${INPUT_TARGET_TOKEN}@${INPUT_TARGET_URL#https://}

case "${GITHUB_EVENT_NAME}" in
push)
git push -f --all target
git push -f --tags target
;;
delete)
git push -d target ${GITHUB_EVENT_REF}
;;
*)
break
;;
esac
19 changes: 19 additions & 0 deletions .github/workflows/git-repo-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: GitlabSync

on:
- push
- delete

jobs:
sync:
runs-on: ubuntu-latest
name: Git Repo Sync
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/git-repo-sync
with:
target-url: ${{ secrets.TARGET_URL }}
target-username: ${{ secrets.TARGET_USERNAME }}
target-token: ${{ secrets.TARGET_TOKEN }}

0 comments on commit 034d7c9

Please sign in to comment.