|
| 1 | +name: Auto YouTube VPS Detection |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 9 * * *' # 每天UTC 9:00运行(调整为您的时区,例如 '0 1 * * *' 为UTC 1:00) |
| 6 | + workflow_dispatch: # 允许手动触发(在GitHub Actions页面) |
| 7 | + |
| 8 | +jobs: |
| 9 | + detect: |
| 10 | + runs-on: ubuntu-latest # 使用最新的Ubuntu虚拟机 |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout repository |
| 14 | + uses: actions/checkout@v4 # 检出仓库代码 |
| 15 | + |
| 16 | + - name: Set up Python |
| 17 | + uses: actions/setup-python@v5 |
| 18 | + with: |
| 19 | + python-version: '3.10' # 使用Python 3.10(可调整) |
| 20 | + |
| 21 | + - name: Install dependencies |
| 22 | + run: | |
| 23 | + python -m pip install --upgrade pip |
| 24 | + pip install -r requirements.txt |
| 25 | +
|
| 26 | + - name: Generate config.json from secrets |
| 27 | + env: |
| 28 | + YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }} |
| 29 | + BARK_SERVER_URL: ${{ secrets.BARK_SERVER_URL }} |
| 30 | + BARK_KEY: ${{ secrets.BARK_KEY }} |
| 31 | + MAX_RESULTS: ${{ secrets.MAX_RESULTS }} |
| 32 | + run: | |
| 33 | + echo '{ |
| 34 | + "youtube_api_key": "'"$YOUTUBE_API_KEY"'", |
| 35 | + "bark_server_url": "'"$BARK_SERVER_URL"'", |
| 36 | + "bark_key": "'"$BARK_KEY"'", |
| 37 | + "max_results": '"$MAX_RESULTS"' |
| 38 | + }' > config.json |
| 39 | +
|
| 40 | + - name: Run detection script |
| 41 | + run: python youtube_vps_detector.py |
| 42 | + |
| 43 | + - name: Clean up config.json (security) |
| 44 | + if: always() # 始终运行,即使前一步失败 |
| 45 | + run: rm -f config.json # 删除生成的config.json,防止泄露 |
0 commit comments