Skip to content

Restore homepage XI servers widget by allowing anonymous access to GET /Banners/GetGameServers #2

Restore homepage XI servers widget by allowing anonymous access to GET /Banners/GetGameServers

Restore homepage XI servers widget by allowing anonymous access to GET /Banners/GetGameServers #2

name: Mirror Issue Labels to PR
on:
pull_request:
types: [opened, reopened, ready_for_review]
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
mirror:
name: Mirror linked issue labels to PR
if: >-
contains(github.event.pull_request.labels.*.name, 'coding-agent') ||
github.event.pull_request.user.login == 'Copilot' ||
github.actor == 'copilot-swe-agent[bot]'
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: read
steps:
- name: Copy labels from linked issue(s)
uses: actions/github-script@v7
with:
script: |
const body = context.payload.pull_request.body || '';
// Strip HTML comments and fenced code blocks before matching, so
// example "Closes #N" lines in template guidance don't trigger.
const stripped = body
.replace(/<!--[\s\S]*?-->/g, '')
.replace(/```[\s\S]*?```/g, '');
// Match "Closes #N", "Fixes #N", "Resolves #N" (case-insensitive,
// with optional ing/d/s suffixes). Only same-repo references are mirrored.
const pattern = /\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)\b/gi;
const issueNumbers = new Set();
let m;
while ((m = pattern.exec(stripped)) !== null) {
issueNumbers.add(parseInt(m[1], 10));
}
if (issueNumbers.size === 0) {
core.info('No "Closes #N" references found in PR body; nothing to mirror.');
return;
}
const prNumber = context.payload.pull_request.number;
const existingLabels = new Set(
(context.payload.pull_request.labels || []).map(l => l.name)
);
const toAdd = new Set();
for (const num of issueNumbers) {
try {
const { data: issue } = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: num,
});
for (const label of issue.labels || []) {
const name = typeof label === 'string' ? label : label.name;
if (!name) continue;
if (existingLabels.has(name)) continue;
toAdd.add(name);
}
} catch (err) {
core.warning(`Failed to fetch issue #${num}: ${err.message}`);
}
}
if (toAdd.size === 0) {
core.info('Linked issue(s) had no new labels to mirror.');
return;
}
const labels = Array.from(toAdd);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
labels,
});
core.info(`Mirrored ${labels.length} label(s) to PR: ${labels.join(', ')}`);