Skip to content

Commit 1d3591e

Browse files
Copilotpaulbkoch
andcommitted
Add documentation for allowing Copilot to run workflows without approval
Co-authored-by: paulbkoch <46825734+paulbkoch@users.noreply.github.com>
1 parent bcfca3c commit 1d3591e

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Allowing Copilot to Run Workflows Without Manual Approval
2+
3+
## Problem
4+
When GitHub Copilot creates a pull request or makes changes, workflows may require manual approval before running. This is a security feature implemented by GitHub to prevent unauthorized workflow execution.
5+
6+
## Solution
7+
8+
The ability to bypass workflow approval for Copilot is **primarily controlled by repository settings**, not the workflow file itself. However, there are several approaches you can take:
9+
10+
### Option 1: Repository Settings (Recommended)
11+
12+
This is the primary way to control workflow approvals for Copilot-created pull requests:
13+
14+
1. **Navigate to Repository Settings**:
15+
- Go to your repository on GitHub
16+
- Click **Settings** > **Actions** > **General**
17+
18+
2. **Configure Fork Pull Request Workflows**:
19+
- Scroll down to **"Fork pull request workflows from contributors"**
20+
- Choose one of the following options based on your security requirements:
21+
- **"Require approval for first-time contributors who are new to GitHub"** (Recommended)
22+
- This allows Copilot (and other established contributors) to run workflows automatically
23+
- Only brand new GitHub users who have never contributed to the repository will need approval
24+
- **"Don't require approval for any contributors"** (Least restrictive)
25+
- All workflows run automatically, including from Copilot
26+
- ⚠️ Use with caution as this reduces security
27+
28+
3. **Click Save**
29+
30+
### Option 2: Repository Rulesets (If Available)
31+
32+
If your repository has rulesets configured, you may be able to add Copilot as a bypass actor:
33+
34+
1. **Navigate to Settings > Rules > Rulesets**
35+
2. **Edit the relevant ruleset** that requires workflow approvals
36+
3. **Add the Copilot coding agent as a bypass actor** (if this option is available)
37+
4. **Save the ruleset**
38+
39+
Note: This feature may not be available in all GitHub plans or may be a newer feature.
40+
41+
### Option 3: Workflow File Modifications (Limited Effectiveness)
42+
43+
While the workflow file itself cannot bypass GitHub's security requirement for bot approvals, you can make some modifications to optimize workflow execution:
44+
45+
#### Use `pull_request_target` Event (Use with Caution)
46+
47+
The `pull_request_target` event runs in the context of the base branch and always executes without approval. However, **this poses security risks** if not used carefully:
48+
49+
```yaml
50+
on:
51+
pull_request: # Standard PR trigger (may require approval)
52+
pull_request_target: # Always runs (security risk if misused)
53+
```
54+
55+
⚠️ **Security Warning**: `pull_request_target` gives the workflow access to repository secrets and runs with write permissions. Only use this for trusted operations that don't execute arbitrary code from the PR.
56+
57+
#### Add Conditional Logic
58+
59+
You can add conditions to skip certain jobs for Copilot if needed:
60+
61+
```yaml
62+
jobs:
63+
my_job:
64+
if: github.actor != 'github-copilot[bot]' && github.actor != 'copilot-autofix[bot]'
65+
runs-on: ubuntu-latest
66+
steps:
67+
# ... your steps
68+
```
69+
70+
Or to run jobs ONLY for Copilot:
71+
72+
```yaml
73+
jobs:
74+
copilot_specific_job:
75+
if: github.actor == 'github-copilot[bot]' || github.actor == 'copilot-autofix[bot]'
76+
runs-on: ubuntu-latest
77+
steps:
78+
# ... your steps
79+
```
80+
81+
## Current Workflow Analysis
82+
83+
The current `interpret-CI` workflow uses the following triggers:
84+
85+
```yaml
86+
on:
87+
push:
88+
pull_request:
89+
workflow_dispatch:
90+
schedule:
91+
```
92+
93+
### Why Approval is Required
94+
95+
- The `pull_request` trigger requires approval for pull requests from users who haven't contributed before (by default)
96+
- This includes bot accounts like Copilot
97+
- This is a GitHub security feature to prevent malicious actors from running arbitrary workflows
98+
99+
### Recommended Action
100+
101+
**The best solution is to adjust the repository settings** as described in Option 1 above. This is:
102+
- ✅ The officially supported method
103+
- ✅ More secure than modifying the workflow file
104+
- ✅ Easier to manage and audit
105+
- ✅ Doesn't require changes to the workflow YAML
106+
107+
## Common Copilot Bot Usernames
108+
109+
When working with conditions, these are common Copilot-related bot usernames:
110+
- `github-copilot[bot]`
111+
- `copilot-autofix[bot]`
112+
113+
## Security Considerations
114+
115+
When allowing workflows to run without approval, consider:
116+
117+
1. **Code Review**: Ensure all code changes are reviewed before merging
118+
2. **Secrets Protection**: Workflows should not expose secrets or sensitive data
119+
3. **Resource Limits**: Workflows should have reasonable timeout and resource constraints
120+
4. **Branch Protection**: Use branch protection rules to prevent direct pushes to important branches
121+
122+
## Further Reading
123+
124+
- [GitHub Docs: Approving workflow runs from public forks](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/approving-workflow-runs-from-public-forks)
125+
- [GitHub Docs: Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository)
126+
- [GitHub Docs: Events that trigger workflows](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows)
127+
128+
## Conclusion
129+
130+
**To allow Copilot to run workflows without approval, you need to change repository settings, not the workflow file.** The workflow file modifications described above provide limited additional control but do not bypass GitHub's core security requirements.
131+
132+
Navigate to **Settings > Actions > General** and adjust the "Fork pull request workflows from contributors" setting to allow Copilot to run workflows automatically.

0 commit comments

Comments
 (0)