Issue
This Content is from Stack Overflow. Question asked by chayanbank
Such as:
source repo on github Branch master -> destination repo on gitlab Branch main
I’m newbie for github action.
How to design a script entrypoint.sh or new pipeline or example for me, please.
Note: sorry, my english not strong.
Workflows: git-repo-sync.yml
name: build
on:
- push
- delete
jobs:
sync:
runs-on: ubuntu-latest
name: Git Repo Sync
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: chayanbank/git-sync@main
with:
target-url: 'https://gitlab.com/chayanbank/test-react-web.git'
target-branch: 'main'
target-username: 'githubsync'
target-token: ${{ secrets.GITHUBSYNC }}
action.yml
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-branch:
description: 'Target Repo Branch'
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_BRANCH: ${{ inputs.target-branch }}
INPUT_TARGET_USERNAME: ${{ inputs.target-username }}
INPUT_TARGET_TOKEN: ${{ inputs.target-token }}
GITHUB_EVENT_REF: ${{ github.event.ref }}
entrypoint.sh
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
Solution
This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.
This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.