github-mirror.yml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. on:
  2. schedule:
  3. - cron: "0 4 * * *" # 北京时间中午12点 (UTC+8) = UTC 04:00
  4. - cron: "0 10 * * *" # 下午六点
  5. - cron: "0 17 * * *" # 凌晨一点
  6. push:
  7. branches:
  8. - master
  9. - dev
  10. pull_request:
  11. name: GitHub-Mirrors
  12. jobs:
  13. run:
  14. name: Run
  15. runs-on: ubuntu-latest
  16. steps:
  17. - name: Get repo and time
  18. id: info
  19. uses: actions/github-script@v3.1
  20. with:
  21. result-encoding: string
  22. script: |
  23. core.setOutput('time', new Date(Date.now()).toISOString().replace(/[^0-9]/g, ""));
  24. core.setOutput('key', `${context.repo.owner}-${context.repo.repo}`);
  25. return context.repo.repo;
  26. - name: Cache src repos
  27. uses: actions/cache@v4
  28. id: cache
  29. with:
  30. path: ${{ github.workspace }}/hub-mirror-cache
  31. key: ${{ runner.os }}-${{ steps.info.outputs.key }}-cache-${{ steps.info.outputs.time }}
  32. restore-keys: ${{ runner.os }}-${{ steps.info.outputs.key }}-cache-
  33. - name: Mirror the GitHub repos to Gitee with cache
  34. uses: Yikun/hub-mirror-action@master
  35. with:
  36. src: github/${{ github.repository_owner }}
  37. dst: gitee/runheng
  38. dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} # 复用公钥
  39. dst_token: ${{ secrets.GITEE_TOKEN }}
  40. clone_style: ssh
  41. static_list: "${{ steps.info.outputs.result }}"
  42. cache_path: /github/workspace/hub-mirror-cache
  43. account_type: user
  44. force_update: true
  45. white_list: "${{ steps.info.outputs.result }}"
  46. - name: Mirror the GitHub repos to GitCode with cache
  47. uses: Yikun/hub-mirror-action@master
  48. with:
  49. src: github/${{ github.repository_owner }}
  50. dst: gitcode/OnmyojiAutoScript
  51. dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} # 复用公钥
  52. dst_token: ${{ secrets.GITCODE_TOKEN }}
  53. clone_style: ssh
  54. static_list: "${{ steps.info.outputs.result }}"
  55. cache_path: /github/workspace/hub-mirror-cache
  56. src_account_type: user
  57. dst_account_type: org
  58. force_update: true
  59. white_list: "${{ steps.info.outputs.result }}"
  60. - name: Print cache path
  61. run: |
  62. ls -la ${{ github.workspace }}/hub-mirror-cache