Telegram Auto Sign #26
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: Telegram Auto Sign | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| run-checkin: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 检出代码 | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: 配置 Python 环境 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: 安装依赖 | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install telethon | |
| - name: 运行签到脚本 | |
| env: | |
| API_ID: ${{ secrets.API_ID }} | |
| API_HASH: ${{ secrets.API_HASH }} | |
| SESSION_STRING: ${{ secrets.SESSION_STRING }} | |
| BOT_USERNAME: ${{ secrets.BOT_USERNAME }} | |
| run: python main.py | |
| - name: 提交日志到 logs 分支 | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| mv checkin.log temp_new_log.txt | |
| git fetch origin logs || true | |
| if git show-ref --verify --quiet refs/remotes/origin/logs; then | |
| git checkout logs | |
| git pull origin logs --rebase | |
| else | |
| git checkout --orphan logs | |
| git rm -rf . | |
| fi | |
| cat temp_new_log.txt >> checkin.log | |
| rm temp_new_log.txt | |
| git add checkin.log | |
| git commit -m "Auto check-in log update: $(date +'%Y-%m-%d %H:%M:%S')" || echo "No changes to commit" | |
| git push origin logs |