Ví dụ bạn muốn mirror 1 repo từ 1 git nào đó ít phổ biến (gitlab/ bitbucket hoặc self-hosted git) về github của mình cho gọn. Nhưng không lẽ hàng ngày lên check xem có gì mới để mirror về ?
Lúc này chỉ cần setup 1 github actions như sau để bạn có thể trigger bằng tay hoặc tự động mỗi 3 tiếng.
name: Mirror Repository
on:
  workflow_dispatch:
  schedule:
    - cron: "10 */3 * * *"
permissions:
  contents: write
jobs:
  mirror:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout repository
      uses: actions/checkout@v3
    - name: Pull code, tags, and branches from the other Git repository
      run: |
        git config --local user.email "[email protected]"
        git config --local user.name "GitHub Action"
        git remote add upstream <GIT_REPO_YOU_WANT_TO_MIRROR>
        git fetch upstream "+refs/heads/*:refs/remotes/upstream/*" --prune
        git fetch upstream "+refs/tags/*:refs/tags/*"
        git merge --allow-unrelated-histories upstream/main
    - name: Push changes to GitHub
      run: |
        git config --local user.email "[email protected]"
        git config --local user.name "GitHub Action"
        git push origin HEAD:main
        git push --tags originArticle Categories:
 config
 
                                        
                
                 
  
  
  
  
  
 