feature(connectors/bright_data_scrape): add Bright Data Web Scraper C… #294
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 Metadata | |
| on: | |
| pull_request_target: | |
| types: [ opened, synchronize, reopened ] | |
| permissions: | |
| pull-requests: write | |
| jobs: | |
| label: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Label PR by size | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| github-token: ${{ github.token }} | |
| script: | | |
| const THRESHOLDS = [ | |
| { max: 19, label: "size/XS" }, | |
| { max: 49, label: "size/S" }, | |
| { max: 199, label: "size/M" }, | |
| { max: 599, label: "size/L" }, | |
| { max: 999, label: "size/XL" }, | |
| { max: Infinity, label: "size/XXL" } | |
| ]; | |
| const COUNT_DELETIONS = true; | |
| function sizeLabel(total) { | |
| return THRESHOLDS.find(t => total <= t.max).label; | |
| } | |
| const { owner, repo } = context.repo; | |
| const prNumber = context.payload.pull_request.number; | |
| const files = await github.paginate( | |
| github.rest.pulls.listFiles, | |
| { owner, repo, pull_number: prNumber, per_page: 100 } | |
| ); | |
| let total = 0; | |
| for (const f of files) { | |
| total += (f.additions || 0); | |
| if (COUNT_DELETIONS) total += (f.deletions || 0); | |
| } | |
| const wanted = sizeLabel(total); | |
| const pr = context.payload.pull_request; | |
| const current = (pr.labels || []).map(l => l.name).filter(n => n.startsWith("size/")); | |
| for (const l of current) { | |
| if (l !== wanted) { | |
| await github.rest.issues.removeLabel({ owner, repo, issue_number: prNumber, name: l }).catch(()=>{}); | |
| } | |
| } | |
| try { | |
| await github.rest.issues.addLabels({ owner, repo, issue_number: prNumber, labels: [wanted] }); | |
| } catch (e) { | |
| throw e; | |
| } | |
| - name: Add default risk and ai-assisted labels | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| github-token: ${{ github.token }} | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const prNumber = context.payload.pull_request.number; | |
| const labels = (context.payload.pull_request.labels || []).map(l => l.name); | |
| const toAdd = []; | |
| if (!labels.some(l => l.startsWith("risk/"))) { | |
| toAdd.push("risk/unknown"); | |
| } | |
| if (!labels.some(l => l.startsWith("ai-assisted/"))) { | |
| toAdd.push("ai-assisted/unknown"); | |
| } | |
| if (toAdd.length > 0) { | |
| await github.rest.issues.addLabels({ owner, repo, issue_number: prNumber, labels: toAdd }); | |
| } |