-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (155 loc) · 6.11 KB
/
agent-ci.yml
File metadata and controls
170 lines (155 loc) · 6.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: "🤖 Autonomous Agent CI/CD"
on:
push:
branches: [main, master]
pull_request:
types: [opened, synchronize, reopened]
issues:
types: [opened, labeled]
schedule:
- cron: '0 6 * * 1'
permissions:
contents: write
pull-requests: write
issues: write
actions: read
security-events: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
detect-and-build:
name: "🔍 Auto-Detect & Build"
runs-on: ubuntu-latest
outputs:
framework: ${{ steps.detect.outputs.framework }}
has_tests: ${{ steps.detect.outputs.has_tests }}
steps:
- uses: actions/checkout@v4
- name: Detect Framework
id: detect
run: |
if [ -f "package.json" ]; then
if grep -q "next" package.json; then echo "framework=nextjs" >> $GITHUB_OUTPUT
elif grep -q "react" package.json; then echo "framework=react" >> $GITHUB_OUTPUT
elif grep -q "vue" package.json; then echo "framework=vue" >> $GITHUB_OUTPUT
else echo "framework=node" >> $GITHUB_OUTPUT; fi
if grep -q '"test"' package.json; then echo "has_tests=true" >> $GITHUB_OUTPUT
else echo "has_tests=false" >> $GITHUB_OUTPUT; fi
if [ -f "pnpm-lock.yaml" ]; then
echo "pkg_manager=pnpm" >> $GITHUB_OUTPUT
elif [ -f "yarn.lock" ]; then
echo "pkg_manager=yarn" >> $GITHUB_OUTPUT
elif [ -f "package-lock.json" ] || [ -f "npm-shrinkwrap.json" ]; then
echo "pkg_manager=npm" >> $GITHUB_OUTPUT
else
echo "pkg_manager=none" >> $GITHUB_OUTPUT
fi
elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
echo "framework=python" >> $GITHUB_OUTPUT
if [ -d "tests" ] || [ -d "test" ]; then echo "has_tests=true" >> $GITHUB_OUTPUT
else echo "has_tests=false" >> $GITHUB_OUTPUT; fi
echo "pkg_manager=none" >> $GITHUB_OUTPUT
elif [ -f "go.mod" ]; then
echo "framework=go" >> $GITHUB_OUTPUT
echo "has_tests=true" >> $GITHUB_OUTPUT
echo "pkg_manager=none" >> $GITHUB_OUTPUT
else
echo "framework=static" >> $GITHUB_OUTPUT
echo "has_tests=false" >> $GITHUB_OUTPUT
echo "pkg_manager=none" >> $GITHUB_OUTPUT
fi
- name: Setup pnpm
if: steps.detect.outputs.pkg_manager == 'pnpm'
uses: pnpm/action-setup@v4
- name: Setup Node (with cache)
if: contains(fromJSON('["nextjs","react","vue","node"]'), steps.detect.outputs.framework) && steps.detect.outputs.pkg_manager != 'none'
uses: actions/setup-node@v4
with:
node-version: '22'
cache: ${{ steps.detect.outputs.pkg_manager }}
- name: Setup Node (no cache)
if: contains(fromJSON('["nextjs","react","vue","node"]'), steps.detect.outputs.framework) && steps.detect.outputs.pkg_manager == 'none'
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install & Build (Node)
if: contains(fromJSON('["nextjs","react","vue","node"]'), steps.detect.outputs.framework)
run: |
if [ "${{ steps.detect.outputs.pkg_manager }}" = "pnpm" ]; then
pnpm install --no-frozen-lockfile
elif [ "${{ steps.detect.outputs.pkg_manager }}" = "yarn" ]; then
yarn install
else
npm ci --ignore-scripts 2>/dev/null || npm install
fi
if [ "${{ steps.detect.outputs.pkg_manager }}" = "pnpm" ]; then
pnpm run build 2>/dev/null || true
else
npm run build --if-present
fi
continue-on-error: true
- name: Test (Node)
if: contains(fromJSON('["nextjs","react","vue","node"]'), steps.detect.outputs.framework) && steps.detect.outputs.has_tests == 'true'
run: |
if [ "${{ steps.detect.outputs.pkg_manager }}" = "pnpm" ]; then
pnpm test 2>/dev/null || true
else
npm test -- --passWithNoTests 2>/dev/null || npm test
fi
continue-on-error: true
- name: Setup Python
if: steps.detect.outputs.framework == 'python'
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install & Test (Python)
if: steps.detect.outputs.framework == 'python'
run: |
pip install -r requirements.txt 2>/dev/null || pip install -e ".[dev]" 2>/dev/null || true
pytest --tb=short 2>/dev/null || true
continue-on-error: true
security-scan:
name: "🛡️ Security Scan"
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'schedule'
steps:
- uses: actions/checkout@v4
- name: Run CodeQL
uses: github/codeql-action/init@v3
with:
languages: javascript-typescript,python
continue-on-error: true
- name: Autobuild
uses: github/codeql-action/autobuild@v3
continue-on-error: true
- name: Analyze
uses: github/codeql-action/analyze@v3
continue-on-error: true
auto-label:
name: "🏷️ Auto-Label PRs"
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/labeler@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
copilot-review:
name: "🧠 Copilot Auto-Review"
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
needs: detect-and-build
steps:
- uses: actions/checkout@v4
- name: Auto-approve safe PRs
if: github.actor == 'dependabot[bot]' || github.actor == 'github-actions[bot]'
run: gh pr review ${{ github.event.pull_request.number }} --approve --body "🤖 Auto-approved (trusted bot)"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Auto-merge Dependabot
if: github.actor == 'dependabot[bot]'
run: gh pr merge ${{ github.event.pull_request.number }} --auto --squash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true