mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-03-27 10:11:48 -04:00
33 lines
1.1 KiB
YAML
33 lines
1.1 KiB
YAML
name: Check PR Labels
|
|
|
|
on:
|
|
pull_request:
|
|
types: [edited, labeled]
|
|
|
|
permissions:
|
|
pull-requests: read
|
|
contents: read
|
|
|
|
jobs:
|
|
check-label:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check for PR labels
|
|
uses: actions/github-script@v8
|
|
with:
|
|
script: |
|
|
// Always fetch the latest labels from the GitHub API to avoid stale context
|
|
const prNumber = context.payload.pull_request.number;
|
|
const { data: pr } = await github.rest.pulls.get({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: prNumber,
|
|
});
|
|
const latestLabels = pr.labels.map(label => label.name);
|
|
const requiredLabels = ['bugfix', 'enhancement', 'automation', 'dependencies', 'repo', 'release', 'refactor'];
|
|
const hasRequiredLabel = latestLabels.some(label => requiredLabels.includes(label));
|
|
console.log('Latest labels:', latestLabels);
|
|
if (!hasRequiredLabel) {
|
|
core.setFailed(`PR must have at least one of the following labels before it can be merged: ${requiredLabels.join(', ')}.`);
|
|
}
|