XT-Bot #105
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: XT-Bot | |
| on: | |
| workflow_dispatch: # 允许手动触发 | |
| # schedule: | |
| # - cron: '*/30 * * * *' # 每30分钟运行 | |
| jobs: | |
| auto-process: | |
| runs-on: ubuntu-latest | |
| env: | |
| TZ: Asia/Shanghai | |
| steps: | |
| - name: Checkout XT-BOT | |
| uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.GH_TOKEN }} | |
| - name: Checkout XT-DATA | |
| uses: actions/checkout@v3 | |
| with: | |
| repository: ${{ github.repository_owner }}/XT-DATA | |
| token: ${{ secrets.GH_TOKEN }} | |
| path: data-repo | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v1 | |
| with: | |
| bun-version: latest | |
| - name: Install Bun dependencies | |
| run: | | |
| cd TypeScript | |
| bun install | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| - name: Install Python dependencies | |
| run: | | |
| cd Python | |
| pip install -r requirements.txt | |
| - name: Sync Data from XT-DATA | |
| run: | | |
| python Python/utils/sync_data.py pull | |
| - name: Create directories | |
| run: | | |
| mkdir -p Artifact | |
| mkdir -p Python/{dataBase,downloads,logs,output} | |
| mkdir -p TypeScript/{data,logs,resp,tweets} | |
| - name: Run fetch script | |
| env: | |
| AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }} | |
| SCREEN_NAME: ${{ secrets.SCREEN_NAME }} | |
| run: | | |
| cd TypeScript/scripts | |
| bun run fetch-following.ts | |
| bun run fetch-home-latest-timeline.ts | |
| - name: Run X-Bot.py | |
| run: | | |
| cd Python/src | |
| python X-Bot.py | |
| - name: Run T-Bot.py | |
| env: | |
| BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | |
| CHAT_ID: ${{ secrets.CHAT_ID }} | |
| LARK_KEY: ${{ secrets.LARK_KEY }} | |
| run: | | |
| cd Python/src | |
| python T-Bot.py | |
| - name: Sync Data to XT-DATA | |
| run: | | |
| python Python/utils/sync_data.py push | |
| - name: Commit & Push XT-DATA | |
| run: | | |
| cd data-repo | |
| git add . | |
| if [ -n "$(git status --porcelain)" ]; then | |
| git config --global user.name "GitHub Actions Bot" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git commit -m "chore: Auto-update from XT-BOT [skip ci]" | |
| git push origin main | |
| else | |
| echo "No changes detected. Skipping commit and push." | |
| fi | |
| - name: Encrypt with py7zr | |
| env: | |
| ARTIFACT_PASS: ${{ secrets.ARTIFACT_PASS }} | |
| TARGET_DIRS: "Python/logs,TypeScript/logs,TypeScript/resp" | |
| OUTPUT_7Z: "Artifact/encrypted_${{ github.run_id }}.7z" | |
| run: | | |
| python Python/utils/encrypt_7z.py "$TARGET_DIRS" "$OUTPUT_7Z" "$ARTIFACT_PASS" | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: workflow_${{ github.run_id }} | |
| path: Artifact/ | |
| retention-days: 7 # 自动清理 |