github action防止被disable 【保活】

      - name: Keepalive Commit
        run: |
          # 1. 进入你 checkout 的代码目录
          cd code 
          
          # 2. 配置 Git 机器人信息
          git config --local user.email "github-actions[bot]@users.noreply.github.com"
          git config --local user.name "github-actions[bot]"
          
          # 3. 更新 heartbeat 文件(即使在 .gitignore 里也没关系)
          echo "Last run: $(date)" > heartbeat.txt
          
          # 4. 强制添加被忽略的文件 (-f 是关键)
          git add -f heartbeat.txt
          
          # 5. 提交更改
          # [skip ci] 是为了防止某些配置下触发死循环,且让 commit 历史更整洁
          git commit -m "chore: keepalive workflow $(date +'%Y-%m-%d %H:%M:%S') [skip ci]" || exit 0
          
          # 6. 推送回主分支
          # HEAD:main 确保推送到你的主分支(如果你的主分支叫 master,请改名)
          git push origin HEAD:${{ github.ref_name }}
 
 
Back to Top