feat: Enhance navbar with login/logout functionality and account menu… #60
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: Smart PR Labeler | |
| on: | |
| pull_request_target: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| label-pr: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout (shallow) | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 # Get minimal history for diff | |
| - name: Label PR by files changed (with auto-create) | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const changedFiles = await github.paginate( | |
| github.rest.pulls.listFiles, { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.payload.pull_request.number, | |
| } | |
| ); | |
| const labelsMap = { | |
| "GitHub Actions": [".github/"], | |
| "Documentation": [".md"], | |
| "CI/CD": [".github/workflows/", ".infisical.json", "next.config.mjs"], | |
| "Frontend": ["components/", "app/", "public/"], | |
| "API": ["app/**/api/", "lib/swagger.ts"], | |
| "Styling": [".css", "tailwind.config", "postcss.config"], | |
| "Dependencies": ["package.json", "package-lock.json"], | |
| "Config": [".config", ".eslintrc", "tsconfig.json", ".gitignore"], | |
| "Models": ["models/"], | |
| "Utils": ["utils/", "lib/"] | |
| }; | |
| const labelsToApply = new Set(); | |
| for (const file of changedFiles) { | |
| const filename = file.filename; | |
| for (const [label, patterns] of Object.entries(labelsMap)) { | |
| if (patterns.some(p => filename.includes(p))) { | |
| labelsToApply.add(label); | |
| } | |
| } | |
| } | |
| let changeCount = 0; | |
| changedFiles.forEach(file => { | |
| changeCount += file.additions + file.deletions; | |
| }); | |
| const size = changeCount <= 9 ? 'XS' : | |
| changeCount <= 49 ? 'S' : | |
| changeCount <= 199 ? 'M' : | |
| changeCount <= 499 ? 'L' : 'XL'; | |
| const sizeLabel = `size-${size}`; | |
| const issue_number = context.payload.pull_request.number; | |
| const prLabels = await github.rest.issues.listLabelsOnIssue({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number | |
| }); | |
| const sizeLabels = prLabels.data.filter(label => label.name.startsWith('size-')); | |
| for (const label of sizeLabels) { | |
| await github.rest.issues.removeLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number, | |
| name: label.name | |
| }); | |
| } | |
| labelsToApply.add(sizeLabel); | |
| const existingLabels = await github.paginate( | |
| github.rest.issues.listLabelsForRepo, { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| } | |
| ); | |
| const existingLabelNames = new Set(existingLabels.map(l => l.name)); | |
| for (const label of labelsToApply) { | |
| if (!existingLabelNames.has(label)) { | |
| await github.rest.issues.createLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| name: label, | |
| color: "0e8a16", // Default green | |
| description: `Auto-generated label for ${label} changes`, | |
| }); | |
| } | |
| } | |
| if (labelsToApply.size > 0) { | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.pull_request.number, | |
| labels: [...labelsToApply], | |
| }); | |
| } else { | |
| console.log("No matching labels found."); | |
| } |