Bump @vercel/speed-insights from 1.1.0 to 1.2.0 #64
Workflow file for this run
This file contains 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 Labeller | |
on: | |
pull_request: | |
types: [opened, edited] | |
jobs: | |
label-pr: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4.2.2 | |
- name: Update PR labels | |
uses: actions/github-script@v7.0.1 | |
with: | |
script: | | |
const prBody = context.payload.pull_request.body; | |
const shouldHaveLabels = new Set(); | |
const labelMappings = { | |
'Bug fix': 'Bug', | |
'New feature': 'Feature', | |
'UI/UX improvement': 'UI/UX', | |
'Weather data processing': 'Data Processing', | |
'Optimisation': 'Optimisation', | |
'Security': 'Security', | |
'Documentation update': 'Documentation', | |
'Chore': 'Chore' | |
}; | |
// Determine which labels should be present | |
for (const [text, label] of Object.entries(labelMappings)) { | |
if (prBody && prBody.includes(`- [x] ${text}`)) { | |
shouldHaveLabels.add(label); | |
} | |
} | |
// Get current labels | |
const currentLabels = await github.rest.issues.listLabelsOnIssue({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.pull_request.number, | |
}); | |
const currentLabelNames = new Set(currentLabels.data.map(l => l.name)); | |
const allMappedLabels = new Set(Object.values(labelMappings)); | |
// Remove labels that shouldn't be there | |
const labelsToRemove = [...currentLabelNames].filter(label => | |
allMappedLabels.has(label) && !shouldHaveLabels.has(label) | |
); | |
for (const label of labelsToRemove) { | |
await github.rest.issues.removeLabel({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.pull_request.number, | |
name: label | |
}); | |
} | |
// Add missing labels | |
const labelsToAdd = [...shouldHaveLabels].filter(label => | |
!currentLabelNames.has(label) | |
); | |
if (labelsToAdd.length > 0) { | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.pull_request.number, | |
labels: labelsToAdd | |
}); | |
} |