Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
name: CodeQL

on:
push:
branches:
- main
- dev
paths:
- "**.cs"
- "**.csproj"

pull_request:
branches:
- "**"

workflow_dispatch:

schedule:
- cron: "31 0 * * 5"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

env:
CI: true

strategy:
fail-fast: false
matrix:
language: ["csharp"]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
dotnet-quality: 'preview'

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
176 changes: 176 additions & 0 deletions .github/workflows/squad-label-enforce.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
---
name: Squad Label Enforce

on:
issues:
types: [labeled]

permissions:
issues: write
contents: read

jobs:
enforce:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Enforce mutual exclusivity
uses: actions/github-script@v7
with:
script: |
const issue = context.payload.issue;
const appliedLabel = context.payload.label.name;

// Namespaces with mutual exclusivity rules
const EXCLUSIVE_PREFIXES = ['go:', 'release:', 'type:', 'priority:'];

// Skip if not a managed namespace label
if (!EXCLUSIVE_PREFIXES.some(p => appliedLabel.startsWith(p))) {
core.info(`Label ${appliedLabel} is not in a managed namespace — skipping`);
return;
}

const allLabels = issue.labels.map(l => l.name);

// Handle go: namespace (mutual exclusivity)
if (appliedLabel.startsWith('go:')) {
const otherGoLabels = allLabels.filter(l =>
l.startsWith('go:') && l !== appliedLabel
);

if (otherGoLabels.length > 0) {
for (const label of otherGoLabels) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
name: label
});
core.info(`Removed conflicting label: ${label}`);
}

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `🏷️ Triage verdict updated → \`${appliedLabel}\``
});
}

if (appliedLabel === 'go:yes') {
const hasReleaseLabel = allLabels.some(l => l.startsWith('release:'));
if (!hasReleaseLabel) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: ['release:backlog']
});

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `📋 Marked as \`release:backlog\` — assign a release target when ready.`
});

core.info('Applied release:backlog for go:yes issue');
}
}

if (appliedLabel === 'go:no') {
const releaseLabels = allLabels.filter(l => l.startsWith('release:'));
if (releaseLabels.length > 0) {
for (const label of releaseLabels) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
name: label
});
core.info(`Removed release label from go:no issue: ${label}`);
}
}
}
}

// Handle release: namespace (mutual exclusivity)
if (appliedLabel.startsWith('release:')) {
const otherReleaseLabels = allLabels.filter(l =>
l.startsWith('release:') && l !== appliedLabel
);

if (otherReleaseLabels.length > 0) {
for (const label of otherReleaseLabels) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
name: label
});
core.info(`Removed conflicting label: ${label}`);
}

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `🏷️ Release target updated → \`${appliedLabel}\``
});
}
}

// Handle type: namespace (mutual exclusivity)
if (appliedLabel.startsWith('type:')) {
const otherTypeLabels = allLabels.filter(l =>
l.startsWith('type:') && l !== appliedLabel
);

if (otherTypeLabels.length > 0) {
for (const label of otherTypeLabels) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
name: label
});
core.info(`Removed conflicting label: ${label}`);
}

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `🏷️ Issue type updated → \`${appliedLabel}\``
});
}
}

// Handle priority: namespace (mutual exclusivity)
if (appliedLabel.startsWith('priority:')) {
const otherPriorityLabels = allLabels.filter(l =>
l.startsWith('priority:') && l !== appliedLabel
);

if (otherPriorityLabels.length > 0) {
for (const label of otherPriorityLabels) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
name: label
});
core.info(`Removed conflicting label: ${label}`);
}

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `🏷️ Priority updated → \`${appliedLabel}\``
});
}
}

core.info(`Label enforcement complete for ${appliedLabel}`);
94 changes: 94 additions & 0 deletions .github/workflows/squad-pr-auto-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
name: Squad PR Auto-Label

on:
pull_request_target:
types: [opened, reopened, synchronize]

permissions:
pull-requests: write

Copilot AI Apr 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow uses github.rest.issues.* APIs to list/add labels and create a comment on the PR, but the workflow-level permissions block does not grant issues: write (or issues: read). With only pull-requests: write, these calls can fail with permission errors. Add issues: write to the permissions (and consider dropping pull-requests: write if it's not otherwise needed).

Suggested change
pull-requests: write
pull-requests: write
issues: write

Copilot uses AI. Check for mistakes.
contents: read

jobs:
auto-label:
runs-on: ubuntu-latest
steps:
- name: Auto-label PR for squad system
uses: actions/github-script@v7
with:
script: |
const pr = context.payload.pull_request;
const author = pr.user.login;

// Fetch current labels on the PR
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number
});

const labelNames = currentLabels.map(l => l.name);

// Check if already has squad labels
const hasSquadLabel = labelNames.some(name =>
name === 'squad' || name.startsWith('squad:')
);

if (hasSquadLabel) {
core.info(`PR #${pr.number} already has squad label(s) — skipping`);
return;
}

let labelsToAdd = [];
let commentBody = '';

// Handle known automation bots
const knownBots = ['dependabot[bot]', 'renovate[bot]', 'github-actions[bot]'];
if (knownBots.includes(author)) {
labelsToAdd = ['squad:boromir', 'squad'];
commentBody = [
`### 🤖 Dependency Update PR`,
'',
`This PR was opened by **${author}** and has been automatically labeled for **Boromir** (DevOps) to review.`,
'',
`**Labels applied:**`,
`- \`squad:boromir\` — Assigned to DevOps for dependency updates`,
`- \`squad\` — In triage queue`,
'',
`> Dependency and infrastructure updates are owned by the DevOps team.`
].join('\n');
} else {
// Handle general PRs without squad labels
labelsToAdd = ['squad'];
commentBody = [
`### 🏗️ PR Added to Squad Triage Queue`,
'',
`This PR has been labeled with \`squad\` and added to the triage queue.`,
'',
`**Next steps:**`,
`- The squad Lead will review and assign to an appropriate team member`,
`- A \`squad:member\` label will be added after triage`,
'',
`> If you know which squad member should handle this, you can add the appropriate \`squad:member\` label yourself.`
].join('\n');
}

// Add labels
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: labelsToAdd
});

core.info(`Added labels to PR #${pr.number}: ${labelsToAdd.join(', ')}`);

// Post comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body: commentBody
});

core.info(`Posted auto-label comment on PR #${pr.number}`);
Loading
Loading