github-mirror.yml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. name: GitHub-Mirror
  10. jobs:
  11. run:
  12. name: Run
  13. runs-on: ubuntu-latest
  14. steps:
  15. - name: Get repo and time
  16. id: info
  17. uses: actions/github-script@v3.1
  18. with:
  19. result-encoding: string
  20. script: |
  21. core.setOutput('time', new Date(Date.now()).toISOString().replace(/[^0-9]/g, ""));
  22. core.setOutput('key', `${context.repo.owner}-${context.repo.repo}`);
  23. return context.repo.repo;
  24. - name: Cache src repos
  25. uses: actions/cache@v4
  26. id: cache
  27. with:
  28. path: ${{ github.workspace }}/hub-mirror-cache
  29. key: ${{ runner.os }}-${{ steps.info.outputs.key }}-cache-${{ steps.info.outputs.time }}
  30. restore-keys: ${{ runner.os }}-${{ steps.info.outputs.key }}-cache-
  31. - name: Mirror the GitHub repos to Gitee with cache
  32. uses: Yikun/hub-mirror-action@master
  33. with:
  34. src: github/runhey
  35. dst: gitee/runheng
  36. dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} # 复用公钥
  37. dst_token: ${{ secrets.GITEE_TOKEN }}
  38. clone_style: ssh
  39. static_list: "${{ steps.info.outputs.result }}"
  40. cache_path: /github/workspace/hub-mirror-cache
  41. account_type: user
  42. force_update: true
  43. white_list: "${{ steps.info.outputs.result }}"
  44. - name: Mirror the GitHub repos to GitCode with cache
  45. uses: Yikun/hub-mirror-action@master
  46. with:
  47. src: github/runhey
  48. dst: gitcode/OnmyojiAutoScript
  49. dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} # 复用公钥
  50. dst_token: ${{ secrets.GITCODE_TOKEN }}
  51. clone_style: ssh
  52. static_list: "${{ steps.info.outputs.result }}"
  53. cache_path: /github/workspace/hub-mirror-cache
  54. src_account_type: user
  55. dst_account_type: org
  56. force_update: true
  57. white_list: "${{ steps.info.outputs.result }}"
  58. - name: Print cache path
  59. run: |
  60. ls -la ${{ github.workspace }}/hub-mirror-cache