github-mirror.yml 2.4 KB

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