PANOPTES Heartbeat #590
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: PANOPTES Heartbeat | |
| on: | |
| schedule: | |
| - cron: '*/30 * * * *' | |
| workflow_dispatch: | |
| inputs: | |
| mode: | |
| description: 'Run mode' | |
| required: true | |
| default: 'full' | |
| type: choice | |
| options: [check, post, engage, full] | |
| jobs: | |
| heartbeat: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - run: pip install -r panoptes/requirements.txt | |
| - uses: actions/cache@v4 | |
| with: | |
| path: panoptes/state/ | |
| key: panoptes-state-${{ github.run_id }} | |
| restore-keys: panoptes-state- | |
| - name: Run heartbeat | |
| env: | |
| MOLTBOOK_API_KEY: ${{ secrets.MOLTBOOK_API_KEY }} | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| run: | | |
| cd panoptes/scripts | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| python heartbeat.py --${{ inputs.mode }} | |
| else | |
| HOUR=$(date -u +%H) | |
| MINUTE=$(date -u +%M) | |
| # Always check for notifications and reply | |
| python heartbeat.py --check | |
| # Engage every 2 hours during active hours (05-23 UTC) | |
| if [[ "$MINUTE" -lt "15" ]] && [[ $(( 10#$HOUR % 2 )) -eq 0 ]] && [[ 10#$HOUR -ge 5 ]] && [[ 10#$HOUR -le 23 ]]; then | |
| python heartbeat.py --engage | |
| sleep 30 | |
| fi | |
| # Post 3x per day: morning, afternoon, evening (08, 15, 21 UTC) | |
| if [[ "$MINUTE" -lt "15" ]] && [[ "$HOUR" == "08" || "$HOUR" == "15" || "$HOUR" == "21" ]]; then | |
| python heartbeat.py --post | |
| fi | |
| fi | |
| - uses: actions/cache/save@v4 | |
| if: always() | |
| with: | |
| path: panoptes/state/ | |
| key: panoptes-state-${{ github.run_id }} |