Daily PXI Digest #90
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: Daily PXI Digest | |
| concurrency: | |
| group: pxi-daily-digest-${{ github.workflow }}-${{ github.ref_name }} | |
| cancel-in-progress: true | |
| on: | |
| schedule: | |
| # Run at both 12:00 and 13:00 UTC; a gate below keeps only true 8:00 AM ET. | |
| - cron: '0 12 * * *' | |
| - cron: '0 13 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| digest: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: production | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Gate scheduled run to 8:00 AM ET | |
| id: et_gate | |
| if: github.event_name == 'schedule' | |
| run: | | |
| set -euo pipefail | |
| et_hour="$(TZ=America/New_York date +%H)" | |
| et_minute="$(TZ=America/New_York date +%M)" | |
| if [[ "$et_hour" != "08" || "$et_minute" != "00" ]]; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| { | |
| echo "### PXI Daily Digest Summary" | |
| echo "" | |
| echo "Skipped scheduled run outside 8:00 AM ET window." | |
| echo "Current ET time: $(TZ=America/New_York date '+%Y-%m-%d %H:%M %Z')" | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Dispatch daily digest | |
| if: github.event_name != 'schedule' || steps.et_gate.outputs.skip != 'true' | |
| env: | |
| WRITE_API_KEY: ${{ secrets.WRITE_API_KEY }} | |
| WRITE_API_URL: ${{ secrets.WRITE_API_URL }} | |
| DIGEST_SUMMARY_PATH: /tmp/pxi-digest-summary.json | |
| run: npm run digest:send | |
| - name: Append digest summary | |
| if: always() | |
| run: | | |
| if [[ -f /tmp/pxi-digest-summary.json ]]; then | |
| { | |
| echo "### PXI Daily Digest Summary" | |
| echo "" | |
| echo "| Sent | Failed | Bounced | Active subscribers |" | |
| echo "|---:|---:|---:|---:|" | |
| jq -r '"| \(.result.sent_count // 0) | \(.result.fail_count // 0) | \(.result.bounce_count // 0) | \(.result.active_subscribers // 0) |"' /tmp/pxi-digest-summary.json | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| else | |
| { | |
| echo "### PXI Daily Digest Summary" | |
| echo "" | |
| echo "No digest summary file produced." | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| fi |