fix: resolve #95 — Document local setup for all Sentri services #9
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: Auto Label PR | |
| on: | |
| pull_request: | |
| types: [opened, edited, synchronize, reopened] | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| issues: write | |
| jobs: | |
| auto-label: | |
| name: auto-label | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Apply labels | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const pr = context.payload.pull_request; | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| const prNumber = pr.number; | |
| const title = pr.title || ""; | |
| const typeMatch = /^(feat|fix|docs|chore|refactor|test|style|perf)\((app|backend|ml-worker|repo|shared)\):\s+.{10,}$/i.exec(title); | |
| const labels = new Set(); | |
| if (typeMatch) { | |
| labels.add(`type:${typeMatch[1].toLowerCase()}`); | |
| const scope = typeMatch[2].toLowerCase(); | |
| labels.add(scope === "shared" ? "area:repo" : `area:${scope}`); | |
| } | |
| const files = await github.paginate(github.rest.pulls.listFiles, { | |
| owner, | |
| repo, | |
| pull_number: prNumber, | |
| per_page: 100, | |
| }); | |
| for (const file of files) { | |
| if (file.filename.startsWith("app/")) labels.add("area:app"); | |
| if (file.filename.startsWith("backend/")) labels.add("area:backend"); | |
| if (file.filename.startsWith("ml-worker/")) labels.add("area:ml-worker"); | |
| if ( | |
| file.filename.startsWith(".github/") || | |
| file.filename === "README.md" || | |
| file.filename.startsWith("docs/") | |
| ) { | |
| labels.add("area:repo"); | |
| } | |
| } | |
| for (const name of labels) { | |
| try { | |
| await github.rest.issues.addLabels({ | |
| owner, | |
| repo, | |
| issue_number: prNumber, | |
| labels: [name], | |
| }); | |
| console.log(`Applied label: ${name}`); | |
| } catch (error) { | |
| core.warning(`Could not apply label "${name}": ${error.message}`); | |
| } | |
| } |