@@ -10,153 +10,107 @@ jobs:
1010 runs-on : ubuntu-latest
1111 if : ${{ !github.event.issue.pull_request }}
1212 steps :
13- - name : Get used package from issue body
13+ - name : Get SDK source from issue body
1414 # https://github.com/actions-ecosystem/action-regex-match
1515 uses : actions-ecosystem/action-regex-match@v2
16- id : packageName
16+ id : sdkSource
1717 with :
18- # Parse used package from issue body
18+ # Parse SDK source from issue body
1919 text : ${{ github.event.issue.body }}
20- regex : ' ### Which SDK are you using \?\n\n(.*)\n\n'
20+ regex : ' ### Where are you installing the Sentry SDK from \?\n\n(.*)\n\n'
2121
22- - name : Map package to issue label
22+ - name : Map SDK source to issue label
2323 # https://github.com/kanga333/variable-mapper
2424 uses : kanga333/variable-mapper@v0.3.0
25- id : packageLabel
26- if : steps.packageName .outputs.match != ''
25+ id : sourceLabel
26+ if : steps.sdkSource .outputs.match != ''
2727 with :
28- key : ' ${{ steps.packageName .outputs.group1 }}'
28+ key : ' ${{ steps.sdkSource .outputs.group1 }}'
2929 # Note: Since this is handled as a regex, and JSON parse wrangles slashes /, we just use `.` instead
3030 map : |
3131 {
32- "@sentry.angular": {
33- "label": "Angular"
34- },
35- "@sentry.astro": {
36- "label": "Astro"
37- },
38- "@sentry.aws-serverless": {
39- "label": "AWS Lambda"
40- },
41- "@sentry.browser": {
42- "label": "Browser"
43- },
44- "@sentry.bun": {
45- "label": "Bun"
46- },
47- "@sentry.cloudflare.-.hono": {
48- "label": "Hono"
49- },
50- "@sentry.cloudflare": {
51- "label": "Cloudflare Workers"
52- },
53- "@sentry.deno": {
54- "label": "Deno"
55- },
56- "@sentry.ember": {
57- "label": "Ember"
58- },
59- "@sentry.gatsby": {
60- "label": "Gatbsy"
61- },
62- "@sentry.google-cloud-serverless": {
63- "label": "Google Cloud Functions"
64- },
65- "@sentry.nestjs": {
66- "label": "Nest.js"
67- },
68- "@sentry.nextjs": {
69- "label": "Next.js"
70- },
71- "@sentry.node.-.express": {
72- "label": "Express"
73- },
74- "@sentry.node.-.fastify": {
75- "label": "Fastify"
76- },
77- "@sentry.node.-.koa": {
78- "label": "Koa"
79- },
80- "@sentry.node.-.hapi": {
81- "label": "Hapi"
82- },
83- "@sentry.node.-.connect": {
84- "label": "Connect"
85- },
86- "@sentry.node": {
87- "label": "Node.js"
88- },
89- "@sentry.nuxt": {
90- "label": "Nuxt"
91- },
92- "@sentry.react-router": {
93- "label": "React Router Framework"
94- },
95- "@sentry.react": {
96- "label": "React"
97- },
98- "@sentry.remix": {
99- "label": "Remix"
100- },
101- "@sentry.solid": {
102- "label": "Solid"
103- },
104- "@sentry.solidstart": {
105- "label": "SolidStart"
106- },
107- "@sentry.sveltekit": {
108- "label": "SvelteKit"
109- },
110- "@sentry.svelte": {
111- "label": "Svelte"
112- },
113- "@sentry.vue": {
114- "label": "Vue"
115- },
116- "@sentry.tanstackstart-react": {
117- "label": "Tanstack Start React"
118- },
119- "@sentry.wasm": {
120- "label": "WASM"
121- },
12232 "Sentry.Browser.Loader": {
123- "label": "Browser "
33+ "label": "Loader Script "
12434 },
12535 "Sentry.Browser.CDN.bundle": {
126- "label": "Browser "
36+ "label": "CDN Bundle "
12737 }
12838 }
12939 export_to : output
13040
131- - name : Add package label if applicable
132- # Note: We only add the label if the issue is still open
133- if : steps.packageLabel.outputs.label != ''
41+ - name : Add SDK source label if applicable
42+ if : steps.sourceLabel.outputs.label != ''
13443 uses : actions-ecosystem/action-add-labels@v1
13544 with :
136- labels : ${{ steps.packageLabel .outputs.label }}
45+ labels : ${{ steps.sourceLabel .outputs.label }}
13746
138- - name : Map additional to issue label
139- # https://github.com/kanga333/variable-mapper
140- uses : kanga333/variable-mapper@v0.3.0
141- id : additionalLabel
142- if : steps.packageName.outputs.match != ''
47+ # Scan System Info section for @sentry/* packages (from envinfo output)
48+ - name : Detect @sentry packages and add labels
49+ uses : actions/github-script@v7
14350 with :
144- key : ' ${{ steps.packageName.outputs.group1 }}'
145- # Note: Since this is handled as a regex, and JSON parse wrangles slashes /, we just use `.` instead
146- map : |
147- {
148- "Sentry.Browser.Loader": {
149- "label": "Loader Script"
150- },
151- "Sentry.Browser.CDN.bundle": {
152- "label": "CDN Bundle"
51+ script : |
52+ const body = context.payload.issue.body || '';
53+
54+ // Extract only the System Info section to avoid matching free-form text
55+ const systemInfoMatch = body.match(/### System Info\s*\n([\s\S]*?)(?=\n### |\n*$)/);
56+ if (!systemInfoMatch) {
57+ console.log('No System Info section found');
58+ return;
59+ }
60+
61+ const systemInfoSection = systemInfoMatch[1];
62+ console.log('Scanning System Info section for @sentry/* packages');
63+
64+ // Map of package patterns to labels
65+ const packageToLabel = {
66+ '@sentry/angular': 'Angular',
67+ '@sentry/astro': 'Astro',
68+ '@sentry/aws-serverless': 'AWS Lambda',
69+ '@sentry/browser': 'Browser',
70+ '@sentry/bun': 'Bun',
71+ '@sentry/cloudflare': 'Cloudflare Workers',
72+ '@sentry/deno': 'Deno',
73+ '@sentry/ember': 'Ember',
74+ '@sentry/gatsby': 'Gatsby',
75+ '@sentry/google-cloud-serverless': 'Google Cloud Functions',
76+ '@sentry/nestjs': 'Nest.js',
77+ '@sentry/nextjs': 'Next.js',
78+ '@sentry/node': 'Node.js',
79+ '@sentry/nuxt': 'Nuxt',
80+ '@sentry/react-router': 'React Router Framework',
81+ '@sentry/react': 'React',
82+ '@sentry/remix': 'Remix',
83+ '@sentry/solid': 'Solid',
84+ '@sentry/solidstart': 'SolidStart',
85+ '@sentry/svelte': 'Svelte',
86+ '@sentry/sveltekit': 'SvelteKit',
87+ '@sentry/tanstackstart-react': 'Tanstack Start React',
88+ '@sentry/vue': 'Vue',
89+ '@sentry/wasm': 'WASM',
90+ };
91+
92+ const labelsToAdd = new Set();
93+
94+ // Check for each package in the System Info section
95+ for (const [pkg, label] of Object.entries(packageToLabel)) {
96+ // Escape special regex characters in package name
97+ const escapedPkg = pkg.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
98+ // Match package name followed by colon (envinfo format) or version pattern
99+ const regex = new RegExp(escapedPkg + '[:\\s]', 'i');
100+ if (regex.test(systemInfoSection)) {
101+ labelsToAdd.add(label);
153102 }
154103 }
155- export_to : output
156104
157- - name : Add additional label if applicable
158- # Note: We only add the label if the issue is still open
159- if : steps.additionalLabel.outputs.label != ''
160- uses : actions-ecosystem/action-add-labels@v1
161- with :
162- labels : ${{ steps.additionalLabel.outputs.label }}
105+ if (labelsToAdd.size > 0) {
106+ const labels = Array.from(labelsToAdd);
107+ console.log('Adding labels:', labels);
108+ await github.rest.issues.addLabels({
109+ owner: context.repo.owner,
110+ repo: context.repo.repo,
111+ issue_number: context.issue.number,
112+ labels: labels
113+ });
114+ } else {
115+ console.log('No @sentry/* packages detected in System Info section');
116+ }
0 commit comments