main.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. name: 'Update schedule'
  2. on:
  3. schedule:
  4. - cron: '0 22 * * *'
  5. - cron: '0 10 * * *'
  6. workflow_dispatch:
  7. branches:
  8. - master
  9. - dev
  10. - gd
  11. jobs:
  12. push:
  13. runs-on: ${{ matrix.operating-system }}
  14. timeout-minutes: 120
  15. strategy:
  16. matrix:
  17. operating-system: [ 'ubuntu-20.04' ]
  18. steps:
  19. - name: Set branch name
  20. id: vars
  21. run: echo "BRANCH_NAME=${{ github.repository_owner == 'Guovin' && 'gd' || 'master' }}" >> $GITHUB_ENV
  22. - uses: actions/checkout@v3
  23. with:
  24. ref: ${{ env.BRANCH_NAME }}
  25. - name: Run with setup-python 3.13
  26. uses: actions/setup-python@v4
  27. with:
  28. python-version: '3.13'
  29. update-environment: true
  30. cache: 'pipenv'
  31. - name: Check open_driver config
  32. id: check_driver
  33. run: |
  34. echo "OPEN_DRIVER=$(python -c '
  35. try:
  36. from utils.config import config
  37. open_driver = config.open_driver
  38. except:
  39. open_driver = False
  40. print(open_driver)')" >> $GITHUB_ENV
  41. - name: Set up Chrome
  42. if: env.OPEN_DRIVER == 'True'
  43. uses: browser-actions/setup-chrome@latest
  44. with:
  45. chrome-version: stable
  46. - name: Download chrome driver
  47. if: env.OPEN_DRIVER == 'True'
  48. uses: nanasess/setup-chromedriver@master
  49. - name: Install FFmpeg
  50. run: sudo apt-get update && sudo apt-get install -y ffmpeg
  51. - name: Install pipenv
  52. run: pip3 install --user pipenv
  53. - name: Install dependecies
  54. run: pipenv --python 3.13 && pipenv install --deploy
  55. - name: Install selenium
  56. if: env.OPEN_DRIVER == 'True'
  57. run: pipenv install selenium
  58. - name: Update
  59. run: pipenv run dev
  60. - name: Commit and push if changed
  61. run: |
  62. git config --local user.email "github-actions[bot]@users.noreply.github.com"
  63. git config --local user.name "github-actions[bot]"
  64. git diff
  65. final_file=$(python -c '
  66. try:
  67. from utils.config import config
  68. final_file = config.final_file
  69. except:
  70. final_file = "output/result.txt"
  71. print(final_file)')
  72. final_m3u_file=$(python -c '
  73. try:
  74. from utils.config import config
  75. import os
  76. final_file = config.final_file
  77. final_m3u_file = os.path.splitext(final_file)[0] + ".m3u"
  78. except:
  79. final_m3u_file = "output/result.m3u"
  80. print(final_m3u_file)')
  81. if [[ -f "$final_file" ]]; then
  82. git add -f "$final_file"
  83. fi
  84. if [[ -f "$final_m3u_file" ]]; then
  85. git add -f "$final_m3u_file"
  86. fi
  87. if [[ -f "output/cache.pkl" ]]; then
  88. git add -f "output/cache.pkl"
  89. fi
  90. if [[ -f "output/sort.log" ]]; then
  91. git add -f "output/sort.log"
  92. fi
  93. if [[ -f "updates/fofa/fofa_hotel_region_result.pkl" ]]; then
  94. git add -f "updates/fofa/fofa_hotel_region_result.pkl"
  95. fi
  96. if [[ -f "updates/fofa/fofa_multicast_region_result.pkl" ]]; then
  97. git add -f "updates/fofa/fofa_multicast_region_result.pkl"
  98. fi
  99. if ! git diff --staged --quiet; then
  100. git commit -m "Github Action Auto Updated"
  101. git push --force
  102. fi