Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fix: added PR reminder action for Dashboard team (#40357)

Ali Waseem1b81ebb7e398
diff --git a/.github/workflows/dashboard-pr-reminder.yml b/.github/workflows/dashboard-pr-reminder.yml
new file mode 100644
index 00000000000..4ba62a53844
--- /dev/null
+++ b/.github/workflows/dashboard-pr-reminder.yml
@@ -0,0 +1,221 @@
+name: Dashboard PR Reminder
+
+on:
+ schedule:
+ # Run at 10am Singapore Time (2am UTC)
+ - cron: '0 2 * * *'
+ # Run at 10am US Eastern Time (2pm UTC = 10am EDT / 9am EST)
+ - cron: '0 14 * * *'
+ workflow_dispatch: # Allow manual trigger for testing
+
+permissions:
+ pull-requests: read
+ contents: read
+
+jobs:
+ check-dashboard-prs:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Find Dashboard PRs older than 24 hours
+ id: find-prs
+ uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
+ with:
+ script: |
+ const TWENTY_FOUR_HOURS_AGO = new Date(Date.now() - 24 * 60 * 60 * 1000);
+ const DASHBOARD_PATH = 'apps/studio/';
+
+ console.log(`Looking for PRs older than: ${TWENTY_FOUR_HOURS_AGO.toISOString()}`);
+
+ const stalePRs = [];
+ let page = 1;
+ let hasMore = true;
+
+ // Fetch PRs page by page, newest first
+ while (hasMore && page <= 10) { // Limit to 10 pages (1000 PRs) as safety measure
+ console.log(`Fetching page ${page}...`);
+
+ const { data: prs } = await github.rest.pulls.list({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ state: 'open',
+ sort: 'created',
+ direction: 'desc',
+ per_page: 100,
+ page: page
+ });
+
+ if (prs.length === 0) {
+ hasMore = false;
+ break;
+ }
+
+ // Check each PR
+ for (const pr of prs) {
+ // Skip PRs from forks - only check internal PRs
+ if (pr.head.repo && pr.head.repo.full_name !== context.repo.owner + '/' + context.repo.repo) {
+ console.log(`PR #${pr.number} is from a fork, skipping...`);
+ continue;
+ }
+
+ // Skip dependabot PRs
+ if (pr.user.login === 'dependabot[bot]' || pr.user.login === 'dependabot') {
+ console.log(`PR #${pr.number} is from dependabot, skipping...`);
+ continue;
+ }
+
+ // Skip draft PRs
+ if (pr.draft) {
+ console.log(`PR #${pr.number} is a draft, skipping...`);
+ continue;
+ }
+
+ const createdAt = new Date(pr.created_at);
+
+ // If this PR is newer than 24 hours, skip it
+ if (createdAt > TWENTY_FOUR_HOURS_AGO) {
+ console.log(`PR #${pr.number} is too new, skipping...`);
+ continue;
+ }
+
+ // If we've reached PRs older than what we're checking, we can stop
+ // But we still need to check if they touch Dashboard files
+ console.log(`Checking PR #${pr.number}: ${pr.title}`);
+
+ // Fetch files changed in this PR
+ const { data: files } = await github.rest.pulls.listFiles({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ pull_number: pr.number,
+ per_page: 100
+ });
+
+ // Check if any file is under apps/studio/
+ const touchesDashboard = files.some(file => file.filename.startsWith(DASHBOARD_PATH));
+
+ if (touchesDashboard) {
+ const hoursOld = Math.floor((Date.now() - createdAt.getTime()) / (1000 * 60 * 60));
+ const daysOld = Math.floor(hoursOld / 24);
+
+ stalePRs.push({
+ number: pr.number,
+ title: pr.title,
+ url: pr.html_url,
+ author: pr.user.login,
+ createdAt: pr.created_at,
+ hoursOld: hoursOld,
+ daysOld: daysOld,
+ fileCount: files.filter(f => f.filename.startsWith(DASHBOARD_PATH)).length
+ });
+
+ console.log(`✓ Found stale Dashboard PR #${pr.number}`);
+ }
+ }
+
+ page++;
+ }
+
+ console.log(`Found ${stalePRs.length} stale Dashboard PRs`);
+
+ // Sort by age (oldest first)
+ stalePRs.sort((a, b) => a.hoursOld - b.hoursOld);
+
+ // Store results for next step
+ core.setOutput('stale_prs', JSON.stringify(stalePRs));
+ core.setOutput('count', stalePRs.length);
+
+ return stalePRs;
+
+ - name: Send Slack notification
+ if: fromJSON(steps.find-prs.outputs.count) > 0
+ uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
+ env:
+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DASHBOARD_WEBHOOK_URL }}
+ STALE_PRS_JSON: ${{ steps.find-prs.outputs.stale_prs }}
+ with:
+ script: |
+ const stalePRs = JSON.parse(process.env.STALE_PRS_JSON);
+ const count = stalePRs.length;
+
+ // Build PR blocks with proper escaping for Slack mrkdwn
+ const prBlocks = stalePRs.map(pr => {
+ // Format age display
+ const remainingHours = pr.hoursOld % 24;
+ const ageText = pr.daysOld > 0
+ ? `${pr.daysOld}d ${remainingHours}h`
+ : `${pr.hoursOld}h`;
+
+ // Escape special characters for Slack mrkdwn (escape &, <, >)
+ const escapeSlack = (text) => {
+ return text
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;');
+ };
+
+ // Truncate title if too long (max 3000 chars for entire text field)
+ const maxTitleLength = 200;
+ const safeTitle = pr.title.length > maxTitleLength
+ ? escapeSlack(pr.title.substring(0, maxTitleLength) + '...')
+ : escapeSlack(pr.title);
+
+ return {
+ type: "section",
+ text: {
+ type: "mrkdwn",
+ text: `*<${pr.url}|#${pr.number}: ${safeTitle}>*\n:bust_in_silhouette: @${pr.author} • :clock3: ${ageText} old • :file_folder: ${pr.fileCount} Dashboard files`
+ }
+ };
+ });
+
+ // Slack has a 50 block limit, we use 3 for header/intro/divider
+ // So we can show max 47 PRs
+ const MAX_PRS_TO_SHOW = 47;
+ const prBlocksToShow = prBlocks.slice(0, MAX_PRS_TO_SHOW);
+ const hasMorePRs = prBlocks.length > MAX_PRS_TO_SHOW;
+
+ // Build complete Slack message
+ const slackMessage = {
+ text: "Dashboard PRs needing attention",
+ blocks: [
+ {
+ type: "header",
+ text: {
+ type: "plain_text",
+ text: "Dashboard PRs Older Than 24 Hours"
+ }
+ },
+ {
+ type: "section",
+ text: {
+ type: "mrkdwn",
+ text: `There are *${count}* open PRs affecting /apps/studio/ that are older than 24 hours:${hasMorePRs ? ` (showing first ${MAX_PRS_TO_SHOW})` : ''}`
+ }
+ },
+ {
+ type: "divider"
+ },
+ ...prBlocksToShow
+ ]
+ };
+
+ // Send to Slack
+ const webhookUrl = process.env.SLACK_WEBHOOK_URL;
+ const response = await fetch(webhookUrl, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(slackMessage)
+ });
+
+ if (!response.ok) {
+ const errorText = await response.text();
+ throw new Error(`Slack notification failed: ${response.status} ${response.statusText}\n${errorText}`);
+ }
+
+ console.log('✓ Slack notification sent successfully!');
+
+ - name: No stale PRs found
+ if: fromJSON(steps.find-prs.outputs.count) == 0
+ run: |
+ echo "✓ No Dashboard PRs older than 24 hours found"