[recipes] Brain backup and export #536
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 PRs | |
| on: | |
| pull_request_target: | |
| types: [opened, synchronize] | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| label: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Detect contribution types and apply labels | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { data: files } = await github.rest.pulls.listFiles({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number, | |
| per_page: 100, | |
| }); | |
| const labels = new Set(); | |
| const pathMap = { | |
| 'recipes/': 'recipe', | |
| 'schemas/': 'schema', | |
| 'dashboards/': 'dashboard', | |
| 'integrations/': 'integration', | |
| 'skills/': 'skill', | |
| 'primitives/': 'primitive', | |
| 'extensions/': 'extension', | |
| }; | |
| for (const file of files) { | |
| for (const [prefix, label] of Object.entries(pathMap)) { | |
| if (file.filename.startsWith(prefix) && !file.filename.includes('_template/')) { | |
| labels.add(label); | |
| } | |
| } | |
| // Label docs and repo-level markdown changes | |
| if (file.filename.startsWith('docs/') || (file.filename.endsWith('.md') && !file.filename.includes('/'))) { | |
| labels.add('documentation'); | |
| } | |
| } | |
| if (labels.size > 0) { | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| labels: [...labels], | |
| }); | |
| console.log(`Applied labels: ${[...labels].join(', ')}`); | |
| } else { | |
| console.log('No contribution directories detected, no labels applied.'); | |
| } |