Skip to content
Open
Changes from 1 commit
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
56 changes: 56 additions & 0 deletions .github/workflows/label-agent-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: label-agent-prs

on:
pull_request:
types:
- opened
- reopened
Comment thread
Copilot marked this conversation as resolved.

permissions:
contents: read
pull-requests: write
issues: write

jobs:
label-agent-prs:
if: github.event.pull_request.user.type == 'Bot' || contains(github.event.pull_request.user.login, 'copilot')
runs-on: ubuntu-latest
steps:
- name: Ensure robot label exists
uses: actions/github-script@v7
with:
script: |
const labelName = 'robot';
const labelColor = '5319E7';
const labelDescription = 'Pull request created by a bot or automated agent';

try {
await github.rest.issues.getLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: labelName,
});
} catch (error) {
if (error.status === 404) {
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: labelName,
color: labelColor,
description: labelDescription,
});
} else {
throw error;
}
}
Comment thread
Copilot marked this conversation as resolved.

- name: Add robot label to PR
uses: actions/github-script@v7
with:
script: |
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ['robot'],
});
Loading