Zero Knowledge Proof Nullifier Consumption Check #11480
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: PR Label Inheritance | |
| on: | |
| pull_request_target: | |
| types: [opened, edited, reopened] | |
| permissions: | |
| issues: read | |
| pull-requests: write | |
| jobs: | |
| inherit-labels: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Inherit Labels from Issues and Add Special Labels | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const pr = context.payload.pull_request; | |
| const body = pr.body || ""; | |
| const prNumber = pr.number; | |
| console.log(`Processing PR #${prNumber}`); | |
| // ── Label categories managed by dedicated workflows ───────────── | |
| // These are intentionally excluded from inheritance to avoid | |
| // conflicts with difficulty.yml, type-labeler.yml, quality-labeler.yml, | |
| // and pr-auto-assign.yml (gssoc:approved). | |
| // Each of those workflows manages its own label namespace exclusively. | |
| const MANAGED_PREFIXES = [ | |
| 'level:', // owned by difficulty.yml | |
| 'type:', // owned by type-labeler.yml | |
| 'quality:', // owned by quality-labeler.yml | |
| 'size/', // owned by pr-size-labeler.yml | |
| 'gssoc:', // owned by pr-auto-assign.yml | |
| 'mentor:', // managed manually by mentors | |
| ]; | |
| function isManagedLabel(name) { | |
| return MANAGED_PREFIXES.some(prefix => name.startsWith(prefix)); | |
| } | |
| // 1. Extract linked issue numbers using regex | |
| // Matching keywords: Fixes, Closes, Resolves, Fixed, Closed, Resolved followed by one or more issue references. | |
| const regex = /(?:fixes|closes|resolves|fixed|closed|resolved)\s*[:\-]?\s*((?:#\d+(?:\s*(?:,|and)\s*)?)+)/gi; | |
| const matches = [...body.matchAll(regex)]; | |
| const linkedIssues = [...new Set( | |
| matches.flatMap(match => [...match[1].matchAll(/#(\d+)/g)].map(issue => parseInt(issue[1], 10))) | |
| )]; | |
| console.log(`Linked issues found: ${linkedIssues.join(', ') || 'None'}`); | |
| const labelsToAdd = new Set(); | |
| // 2. Fetch labels from linked issues (skip managed-prefix labels) | |
| for (const issueNumber of linkedIssues) { | |
| try { | |
| const { data: issue } = await github.rest.issues.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber | |
| }); | |
| if (issue.labels && issue.labels.length > 0) { | |
| for (const label of issue.labels) { | |
| const labelName = typeof label === 'string' ? label : label.name; | |
| if (isManagedLabel(labelName)) { | |
| console.log(`Skipping managed label "${labelName}" from issue #${issueNumber} (handled by dedicated workflow)`); | |
| continue; | |
| } | |
| labelsToAdd.add(labelName); | |
| console.log(`Inheriting label "${labelName}" from issue #${issueNumber}`); | |
| } | |
| } | |
| } catch (error) { | |
| console.warn(`Could not fetch details for issue #${issueNumber}: ${error.message}`); | |
| } | |
| } | |
| // 3. Hacktoberfest Label Check | |
| const createdAt = new Date(pr.created_at); | |
| if (createdAt.getMonth() === 9) { // 9 is October (0-indexed) | |
| labelsToAdd.add('hacktoberfest-accepted'); | |
| console.log('PR created in October. Adding "hacktoberfest-accepted" label.'); | |
| } | |
| // 4. Apply labels — only add ones not already on the PR (idempotency guard) | |
| if (labelsToAdd.size > 0) { | |
| // Fetch current PR labels to avoid re-adding existing ones | |
| const { data: currentIssue } = await github.rest.issues.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber | |
| }); | |
| const currentLabels = new Set(currentIssue.labels.map(l => (typeof l === 'string' ? l : l.name))); | |
| const newLabels = [...labelsToAdd].filter(l => !currentLabels.has(l)); | |
| if (newLabels.length > 0) { | |
| console.log(`Applying inherited labels to PR #${prNumber}: ${newLabels.join(', ')}`); | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| labels: newLabels | |
| }); | |
| } else { | |
| console.log('All inherited labels are already present on this PR — skipping.'); | |
| } | |
| } else { | |
| console.log('No labels to inherit for this PR.'); | |
| } |