Premature 'SUBSCRIBED' status for postgres_changes signals incorrect readiness #9
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: Label Issues | |
on: | |
issues: | |
types: | |
- opened | |
- transferred | |
permissions: | |
issues: write | |
jobs: | |
label-issue: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Label based on source repository, template field, or title | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
// Define the mapping from repo/template value to label | |
const labelMap = { | |
'supabase/auth-js': 'auth-js', | |
'supabase/functions-js': 'functions-js', | |
'supabase/postgrest-js': 'postgrest-js', | |
'supabase/storage-js': 'storage-js', | |
'supabase/realtime-js': 'realtime-js', | |
'auth-js': 'auth-js', | |
'functions-js': 'functions-js', | |
'postgrest-js': 'postgrest-js', | |
'storage-js': 'storage-js', | |
'realtime-js': 'realtime-js', | |
}; | |
let labels = []; | |
if (context.payload.action === 'transferred') { | |
// Label based on source repository | |
const sourceRepo = context.payload.changes?.old_repository?.full_name || context.payload.changes?.from?.full_name || context.payload.changes?.new_repository?.full_name; | |
const label = labelMap[sourceRepo]; | |
if (label) labels.push(label); | |
} else if (context.payload.action === 'opened') { | |
// Label based on "Library affected" field in the issue body | |
const body = context.payload.issue.body || ''; | |
const match = body.match(/### Library affected\s*\n+([\s\S]*?)(\n###|\n$)/i); | |
if (match) { | |
const libsRaw = match[1]; | |
// Split by comma, semicolon, or newlines | |
const libs = libsRaw.split(/,|;|\n/).map(s => s.trim().toLowerCase()).filter(Boolean); | |
for (const lib of libs) { | |
if (labelMap[lib]) labels.push(labelMap[lib]); | |
} | |
} | |
} | |
// Check the title for "[migration]" | |
const title = context.payload.issue.title || ''; | |
if (title.toLowerCase().includes('[migration]')) { | |
labels.push('migration'); | |
} | |
// Remove duplicates | |
labels = [...new Set(labels)]; | |
if (labels.length > 0) { | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.issue.number, | |
labels, | |
}); | |
} else { | |
console.log('No matching label found; no label added.'); | |
} |