diff --git a/.github/workflows/pr-feature-label.yml b/.github/workflows/pr-feature-label.yml new file mode 100644 index 000000000..c3c2b9027 --- /dev/null +++ b/.github/workflows/pr-feature-label.yml @@ -0,0 +1,56 @@ +name: PR Feature Label + +on: + pull_request: + types: [opened] + +jobs: + label: + runs-on: ubuntu-latest + # Skip fork PRs (read-only token can't label) and dependabot — matches repo convention + if: github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' + permissions: + issues: write # create the label if it doesn't exist yet + pull-requests: write # add the label to the PR + steps: + - uses: actions/github-script@v8 + with: + script: | + const prefix = 'feature/'; + const pr = context.payload.pull_request; + + // Label whichever side of the PR is a feature branch: + // - base is feature/* : a PR merging INTO a long-lived feature branch + // - head is feature/* : a feature branch being merged into main (or elsewhere) + // Both produce a "feature:" label; if both sides qualify, both are applied. + const labels = [...new Set( + [pr.base.ref, pr.head.ref] + .filter((ref) => ref.startsWith(prefix)) + .map((ref) => `feature:${ref.slice(prefix.length)}`) + )]; + + if (labels.length === 0) { + console.log(`Neither base "${pr.base.ref}" nor head "${pr.head.ref}" is a feature branch; nothing to do.`); + return; + } + + // Create any labels that don't exist yet (auto-created gray). + for (const label of labels) { + try { + await github.rest.issues.getLabel({ ...context.repo, name: label }); + } catch (error) { + if (error.status === 404) { + await github.rest.issues.createLabel({ ...context.repo, name: label, color: 'ededed' }); + console.log(`Created label "${label}"`); + } else { + throw error; + } + } + } + + await github.rest.issues.addLabels({ + ...context.repo, + issue_number: pr.number, + labels, + }); + console.log(`Applied label(s) ${labels.map((l) => `"${l}"`).join(', ')} to PR #${pr.number}`); diff --git a/.gitignore b/.gitignore index 926ed24c2..80e0c1837 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ tableau-mcp.mcpb *.tgz *.tar.gz *.zip +.DS_Store # MCP Apps src/web/apps/dist/