Skip to content

Commit 2cc3810

Browse files
brunoborgesCopilot
andcommitted
Add CI guard to block forbidden files in workflows/
Prevents contributors from pushing compiled YAML (.yml, .yaml, .lock.yml) or .github/ directories into the workflows/ directory. Only .md markdown source files are accepted — compilation happens downstream via gh aw compile. This is a security measure to prevent malicious GitHub Actions code from being introduced through contributed agentic workflows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 68c5ef5 commit 2cc3810

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Block Forbidden Workflow Contribution Files
2+
3+
on:
4+
pull_request:
5+
branches: [staged]
6+
types: [opened, synchronize, reopened]
7+
paths:
8+
- "workflows/**"
9+
10+
permissions:
11+
contents: read
12+
pull-requests: write
13+
14+
jobs:
15+
check-forbidden-files:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Check for forbidden files in workflows/
24+
id: check
25+
run: |
26+
# Check for YAML/lock files in workflows/ and any .github/ modifications
27+
forbidden=$(git diff --name-only --diff-filter=ACM origin/${{ github.base_ref }}...HEAD -- \
28+
'workflows/**/*.yml' \
29+
'workflows/**/*.yaml' \
30+
'workflows/**/*.lock.yml' \
31+
'.github/*' \
32+
'.github/**')
33+
34+
if [ -n "$forbidden" ]; then
35+
echo "❌ Forbidden files detected:"
36+
echo "$forbidden"
37+
echo "files<<EOF" >> "$GITHUB_OUTPUT"
38+
echo "$forbidden" >> "$GITHUB_OUTPUT"
39+
echo "EOF" >> "$GITHUB_OUTPUT"
40+
exit 1
41+
else
42+
echo "✅ No forbidden files found in workflows/"
43+
fi
44+
45+
- name: Comment on PR
46+
if: failure()
47+
uses: marocchino/sticky-pull-request-comment@v2
48+
with:
49+
header: workflow-forbidden-files
50+
message: |
51+
## 🚫 Forbidden files in `workflows/`
52+
53+
Only `.md` markdown files are accepted in the `workflows/` directory. The following are **not allowed**:
54+
- Compiled workflow files (`.yml`, `.yaml`, `.lock.yml`) — could contain untrusted Actions code
55+
- `.github/` modifications — workflow contributions must not modify repository configuration
56+
57+
**Files that must be removed:**
58+
```
59+
${{ steps.check.outputs.files }}
60+
```
61+
62+
Contributors provide the workflow **source** (`.md`) only. Compilation happens downstream via `gh aw compile`.
63+
64+
Please remove these files and push again.

0 commit comments

Comments
 (0)