name: continuous-cron on: schedule: # 每 2 分钟触发一次,方便观察连续定时任务 - cron: "*/2 * * * *" workflow_dispatch: jobs: prepare: runs-on: ubuntu-latest steps: - name: checkout uses: actions/checkout@v4 - name: prepare marker run: | echo "prepare at $(date -u +%Y-%m-%dT%H:%M:%SZ)" echo "run_id=${{ github.run_id }}" echo "event=${{ github.event_name }}" mkdir -p artifacts echo "prepared" > artifacts/prepare.txt cat artifacts/prepare.txt work: runs-on: ubuntu-latest needs: prepare steps: - name: checkout uses: actions/checkout@v4 - name: run business task env: TASK_OUT_DIR: artifacts run: | python3 app/task.py ls -la artifacts - name: simulate work run: | echo "working..." sleep 3 echo "work done" report: runs-on: ubuntu-latest needs: work steps: - name: summary run: | echo "## Continuous Cron Report" >> $GITHUB_STEP_SUMMARY echo "- run_id: ${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY echo "- event: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY echo "- time_utc: $(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_STEP_SUMMARY echo "report finished at $(date -u +%Y-%m-%dT%H:%M:%SZ)"