From 7d6142e8e46a3007fbb965dc3d8173df0004ef78 Mon Sep 17 00:00:00 2001 From: Sanjay Rai Date: Wed, 20 Nov 2024 03:58:35 -0800 Subject: [PATCH] next attempt --- scripts/record-web-vitals.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/record-web-vitals.js b/scripts/record-web-vitals.js index ecfec712..e3e0ba1b 100644 --- a/scripts/record-web-vitals.js +++ b/scripts/record-web-vitals.js @@ -7,6 +7,9 @@ const execPromise = util.promisify(exec); async function collectMetrics() { // Check for both PR merge and direct push to main const isMergeContext = ( + // If we have PR_NUMBER, treat it as a PR merge + process.env.PR_NUMBER || + // Otherwise use the original conditions (process.env.GITHUB_EVENT_NAME === 'pull_request' && process.env.GITHUB_EVENT_ACTION === 'closed' && process.env.GITHUB_PULL_REQUEST_MERGED === 'true') || @@ -14,6 +17,15 @@ async function collectMetrics() { process.env.GITHUB_REF === 'refs/heads/main') ); + // Always use PR information if available + const prInfo = process.env.PR_NUMBER ? { + number: process.env.PR_NUMBER, + title: process.env.PR_TITLE + } : { + number: process.env.GITHUB_SHA?.substring(0, 7) || 'unknown', + title: 'Direct push to main' + }; + console.log('Environment variables:', { GITHUB_EVENT_NAME: process.env.GITHUB_EVENT_NAME, GITHUB_EVENT_ACTION: process.env.GITHUB_EVENT_ACTION, @@ -61,13 +73,7 @@ async function collectMetrics() { const record = { date: new Date().toISOString(), - pr: process.env.GITHUB_EVENT_NAME === 'pull_request' ? { - number: process.env.PR_NUMBER || 'unknown', - title: process.env.PR_TITLE || 'unknown' - } : { - number: process.env.GITHUB_SHA?.substring(0, 7) || 'unknown', - title: 'Direct push to main' - }, + pr: prInfo, metrics: currentMetrics.metrics };