feat!: retire weekly leaderboard prize tier (#886) #519
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: Preview | |
| on: | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: preview-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| preview: | |
| if: github.event.pull_request.head.repo.fork == false | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| - run: npm ci | |
| - run: npm run typecheck | |
| - name: Deploy preview | |
| id: deploy | |
| run: | | |
| set +e | |
| OUTPUT=$(npx wrangler deploy --env staging 2>&1) | |
| EXIT_CODE=$? | |
| set -e | |
| echo "$OUTPUT" | |
| if [ $EXIT_CODE -ne 0 ]; then | |
| echo "::error::wrangler deploy failed with exit code $EXIT_CODE" | |
| exit $EXIT_CODE | |
| fi | |
| URL=$(echo "$OUTPUT" | grep -Eo 'https://[^[:space:]]*\.workers\.dev' | head -1) | |
| echo "url=$URL" >> "$GITHUB_OUTPUT" | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| - name: Seed preview data | |
| run: | | |
| URL="${{ steps.deploy.outputs.url }}" | |
| if [ -z "$URL" ]; then | |
| URL="https://agent-news-staging.hosting-962.workers.dev" | |
| fi | |
| echo "Preview URL: $URL" | |
| # Warm up the DO (triggers schema migrations + beat seeding) | |
| echo "Warming up DO..." | |
| curl -s -o /dev/null -w "beats: HTTP %{http_code}\n" "$URL/api/beats" || true | |
| # Seed sample signals, tags, and streaks | |
| echo "Seeding data..." | |
| curl -s -w "\nseed: HTTP %{http_code}\n" -X POST "$URL/api/internal/seed" \ | |
| -H "Content-Type: application/json" \ | |
| -H "X-Migration-Key: $STAGING_MIGRATION_KEY" \ | |
| -d @fixtures/seed-staging.json | |
| env: | |
| STAGING_MIGRATION_KEY: ${{ secrets.STAGING_MIGRATION_KEY }} | |
| - name: Comment preview URL | |
| uses: actions/github-script@v7 | |
| env: | |
| PREVIEW_URL: ${{ steps.deploy.outputs.url }} | |
| with: | |
| script: | | |
| const url = process.env.PREVIEW_URL; | |
| const body = url | |
| ? `**Preview deployed:** ${url}\n\nThis preview uses sample data — beats, signals, and streaks are seeded automatically.` | |
| : `**Preview deployed** to \`agent-news-staging.workers.dev\` (URL not detected in deploy output).\n\nSample data was seeded automatically.`; | |
| const comments = await github.paginate(github.rest.issues.listComments, { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const botComment = comments.find(c => | |
| c.user.type === 'Bot' && c.body.startsWith('**Preview deployed') | |
| ); | |
| if (botComment) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body, | |
| }); | |
| } |