feat: newsletter on happiness and longevity #48
Workflow file for this run
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: Sync Newsletter to Resend | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize] | |
| paths: | |
| - 'src/data/newsletters/**' | |
| jobs: | |
| sync: | |
| permissions: | |
| contents: read | |
| pull-requests: write # Allow commenting on PRs | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # Need full history for git diff | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: 'package.json' | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Sync newsletters to Resend | |
| env: | |
| RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }} | |
| RESEND_NEWSLETTER_AUDIENCE_ID: ${{ secrets.RESEND_NEWSLETTER_AUDIENCE_ID }} | |
| RESEND_SIGNING_SECRET: ${{ secrets.RESEND_SIGNING_SECRET }} | |
| # Client-side env vars (not used by script but required by env.ts validation) | |
| NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME: ${{ secrets.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME }} | |
| NEXT_PUBLIC_FATHOM_ID: ${{ secrets.NEXT_PUBLIC_FATHOM_ID }} | |
| NEXT_PUBLIC_POSTHOG_KEY: ${{ secrets.NEXT_PUBLIC_POSTHOG_KEY }} | |
| run: pnpm tsx scripts/sync-newsletter-to-resend.ts | |
| - name: Comment on PR (on failure) | |
| if: failure() | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| github.rest.pulls.createReviewComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number, | |
| body: '❌ Newsletter sync to Resend failed. Check the [workflow logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.', | |
| commit_id: context.payload.pull_request.head.sha, | |
| path: 'src/data/newsletters', | |
| line: 1 | |
| }) |