Add skip-roles to conditionally skip workflows based on repository permissions#15988
Add skip-roles to conditionally skip workflows based on repository permissions#15988
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add skip-roles: [admin, maintainer, write, triage] to ai-moderator.md - Remove custom check_external_user job (replaced by skip-roles) - Fix buildPreActivationAndActivationJobs to trigger on skip-roles and rate-limit - Update logging to include hasSkipRoles and hasRateLimit flags Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added skip-roles: [admin, maintainer, write, triage] to ai-moderator.md and removed the custom check_external_user job. The workflow now uses the native skip-roles feature in pre-activation. (9a17b71) Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot merge main and recompile |
…dd-skip-roles-option
Merged main branch and recompiled all 154 workflows successfully. The merge commit (c822101) includes upstream changes to unlock job handling and other improvements. All skip-roles tests pass. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot lint go |
There was a problem hiding this comment.
Pull request overview
This PR adds a skip-roles feature that allows workflows to conditionally skip execution based on repository permissions. The primary use case is AI moderation workflows that should only run for external contributors, not team members with elevated permissions.
Changes:
- Added
skip-rolesconfiguration in theon:section (schema, extraction, YAML processing) - Implemented pre-activation check via
check_skip_roles.cjsthat queries GitHub API for user permissions - Updated pre-activation trigger logic to create pre_activation job when skip-roles or rate-limit are configured, even if
roles: allis set - Applied the feature to AI moderator workflow, removing 87 lines of custom permission checking code
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
pkg/parser/schemas/main_workflow_schema.json |
Added schema definition for skip-roles field supporting string or array format |
pkg/constants/constants.go |
Added CheckSkipRolesStepID and SkipRolesOkOutput constants |
pkg/workflow/compiler_types.go |
Added SkipRoles field to WorkflowData struct |
pkg/workflow/role_checks.go |
Added extractSkipRoles() and extractStringSliceField() helper functions |
pkg/workflow/compiler_orchestrator_workflow.go |
Integrated skip-roles extraction into workflow compilation |
pkg/workflow/compiler_jobs.go |
Updated pre-activation trigger condition to include hasSkipRoles and hasRateLimit flags |
pkg/workflow/compiler_activation_jobs.go |
Added skip-roles check step generation and condition to pre-activation job |
pkg/workflow/frontmatter_extraction_yaml.go |
Added YAML commenting logic for skip-roles field |
pkg/workflow/skip_roles_test.go |
Comprehensive tests for skip-roles feature including edge cases |
actions/setup/js/check_skip_roles.cjs |
JavaScript implementation using shared permission checking utility |
actions/setup/js/check_skip_roles.test.cjs |
Comprehensive unit tests for the JavaScript implementation |
.github/workflows/ai-moderator.md |
Applied skip-roles to AI moderator, replacing custom permission check |
.github/workflows/ai-moderator.lock.yml |
Compiled workflow with skip-roles pre-activation check |
.github/workflows/bot-detection.lock.yml |
Recompiled workflow with mention normalization (@pelikhan → pelikhan) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implementation Plan for skip-roles Feature
This feature adds
on.skip-roles: [...]to skip workflows for specified roles (e.g., admin, maintainer).onsectionOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.