-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
130 lines (114 loc) · 3.88 KB
/
Copy pathaction.yml
File metadata and controls
130 lines (114 loc) · 3.88 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
name: 'autoforge-improve'
description: 'Analyze repository health and propose/execute improvement goals'
branding:
icon: 'zap'
color: 'orange'
inputs:
max-goals:
description: 'Maximum number of goals to report'
required: false
default: '5'
create-issue:
description: 'Create a GitHub Issue with improvement proposals'
required: false
default: 'true'
comment-on-pr:
description: 'Post score summary as PR comment'
required: false
default: 'true'
fail-below:
description: 'Fail the action if health score is below this (0-100)'
required: false
default: '0'
outputs:
score:
description: 'Repository health score (0-100)'
value: ${{ steps.score.outputs.total }}
grade:
description: 'Repository health grade (A/B/C/D/F)'
value: ${{ steps.score.outputs.grade }}
runs:
using: 'composite'
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install autoforge
shell: bash
run: pip install -e ${{ github.action_path }}
- name: Compute health score
id: score
shell: bash
run: |
autoforge-score --json > /tmp/autoforge-score.json
cat /tmp/autoforge-score.json
total=$(python3 -c "import json; print(json.load(open('/tmp/autoforge-score.json'))['total'])")
grade=$(python3 -c "import json; print(json.load(open('/tmp/autoforge-score.json'))['grade'])")
echo "total=$total" >> $GITHUB_OUTPUT
echo "grade=$grade" >> $GITHUB_OUTPUT
autoforge-score > /tmp/score-report.txt
cat /tmp/score-report.txt
- name: Run improvement analysis
id: analyze
shell: bash
run: |
autoforge-improve --dry-run > /tmp/autoforge-report.txt 2>&1
cat /tmp/autoforge-report.txt
- name: Check fail threshold
if: inputs.fail-below != '0'
shell: bash
run: |
total="${{ steps.score.outputs.total }}"
threshold="${{ inputs.fail-below }}"
if [ "$total" -lt "$threshold" ]; then
echo "::error::Health score $total% is below threshold $threshold%"
exit 1
fi
- name: Comment on PR
if: inputs.comment-on-pr == 'true' && github.event_name == 'pull_request'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr comment ${{ github.event.pull_request.number }} --body "$(cat <<BODY
## 🔍 autoforge Health Report
**Score: ${{ steps.score.outputs.total }}% (Grade ${{ steps.score.outputs.grade }})**
\`\`\`
$(cat /tmp/score-report.txt)
\`\`\`
### Improvement Proposals
\`\`\`
$(cat /tmp/autoforge-report.txt)
\`\`\`
---
*Generated by [autoforge](https://github.com/shigel/autoforge)*
BODY
)" || echo "PR comment skipped"
- name: Create Issue
if: inputs.create-issue == 'true' && github.event_name != 'pull_request'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
existing=$(gh issue list --label "autoforge" --state open --json number -q 'length')
if [ "$existing" != "0" ] && [ -n "$existing" ]; then
echo "Autoforge issue already exists, skipping"
exit 0
fi
gh issue create \
--title "autoforge: Health ${{ steps.score.outputs.total }}% (${{ steps.score.outputs.grade }}) — improvements available" \
--label "autoforge" \
--body "$(cat <<BODY
## Repository Health: ${{ steps.score.outputs.total }}% (Grade ${{ steps.score.outputs.grade }})
\`\`\`
$(cat /tmp/score-report.txt)
\`\`\`
### Improvement Proposals
\`\`\`
$(cat /tmp/autoforge-report.txt)
\`\`\`
---
*Generated by [autoforge](https://github.com/shigel/autoforge)*
BODY
)" || echo "Issue creation skipped"