Files
awesome-copilot/.github/workflows/external-plugin-approval-command.yml
T
2026-06-10 05:15:22 +00:00

71 lines
2.2 KiB
YAML

name: External Plugin Approval Commands
on:
pull_request:
types: [closed]
concurrency:
group: external-plugin-approval-pr-${{ github.event.pull_request.number }}
cancel-in-progress: false
permissions:
issues: write
jobs:
sync-merged-pr-labels:
runs-on: ubuntu-latest
if: >-
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'external-plugin')
steps:
- name: Normalize merged external plugin PR labels
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
with:
script: |
const prNumber = context.payload.pull_request.number;
const staleLabels = ['awaiting-review', 'awaiting-approval', 'ready-for-review', 'rejected'];
try {
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'approved',
color: '1D76DB',
description: 'Submission was approved by a maintainer'
});
} catch (error) {
if (error.status !== 422) {
throw error;
}
}
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
per_page: 100
});
const labelNames = new Set(currentLabels.map((label) => label.name));
if (!labelNames.has('approved')) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
labels: ['approved']
});
}
for (const labelName of staleLabels) {
if (!labelNames.has(labelName)) {
continue;
}
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
name: labelName
});
}