|
| 1 | +name: Daily Activity |
| 2 | + |
| 3 | +# Runs at 11:55 PM UTC daily (safety net for contribution graph) |
| 4 | +# Only creates a commit if no other commits were made that day |
| 5 | + |
| 6 | +on: |
| 7 | + schedule: |
| 8 | + - cron: '55 23 * * *' # 11:55 PM UTC daily |
| 9 | + workflow_dispatch: # Allow manual trigger |
| 10 | + |
| 11 | +jobs: |
| 12 | + heartbeat: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: write |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 # Full history for commit checking |
| 22 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + |
| 24 | + - name: Check for today's commits |
| 25 | + id: check |
| 26 | + run: | |
| 27 | + TODAY=$(date -u +%Y-%m-%d) |
| 28 | + echo "Checking for commits on $TODAY..." |
| 29 | +
|
| 30 | + # Count commits from today (excluding bot commits) |
| 31 | + COMMITS=$(git log --since="$TODAY 00:00:00 UTC" --until="$TODAY 23:59:59 UTC" \ |
| 32 | + --oneline --author-date-order \ |
| 33 | + --invert-grep --grep="Daily heartbeat" | wc -l) |
| 34 | +
|
| 35 | + echo "Found $COMMITS human commits today" |
| 36 | + echo "commits=$COMMITS" >> $GITHUB_OUTPUT |
| 37 | +
|
| 38 | + - name: Create heartbeat commit if no activity |
| 39 | + if: steps.check.outputs.commits == '0' |
| 40 | + run: | |
| 41 | + # Create or update heartbeat file |
| 42 | + mkdir -p .github |
| 43 | + cat > .github/HEARTBEAT << EOF |
| 44 | + # RISKCORE Development Heartbeat |
| 45 | +
|
| 46 | + Last active: $(date -u +%Y-%m-%d) |
| 47 | + Timestamp: $(date -u +%Y-%m-%dT%H:%M:%SZ) |
| 48 | +
|
| 49 | + This file is automatically updated to maintain contribution activity. |
| 50 | + Real development happens in the codebase - this is just a safety net. |
| 51 | + EOF |
| 52 | +
|
| 53 | + # Configure git |
| 54 | + git config user.name "github-actions[bot]" |
| 55 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 56 | +
|
| 57 | + # Commit and push |
| 58 | + git add .github/HEARTBEAT |
| 59 | + git commit -m "chore: Daily heartbeat [skip ci]" |
| 60 | + git push |
| 61 | +
|
| 62 | + - name: Skip message |
| 63 | + if: steps.check.outputs.commits != '0' |
| 64 | + run: | |
| 65 | + echo "Found ${{ steps.check.outputs.commits }} commits today - no heartbeat needed!" |
0 commit comments