-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
122 lines (115 loc) · 4.27 KB
/
Copy pathaction.yml
File metadata and controls
122 lines (115 loc) · 4.27 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
name: agent-ready
description: Score a repository for AI coding agent readiness.
author: EShener
branding:
icon: check-circle
color: green
inputs:
fail-under:
description: Minimum Agent Readiness Score required for the check to pass.
required: false
default: "80"
working-directory:
description: Repository subdirectory to score.
required: false
default: "."
config:
description: Optional path to agent-ready.json, relative to the working directory.
required: false
default: ""
comment:
description: Post or update an agent-ready summary comment on pull requests.
required: false
default: "false"
github-token:
description: GitHub token used when comment is true.
required: false
default: ${{ github.token }}
runs:
using: composite
steps:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Write agent-ready summary
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
if [ -z "${GITHUB_STEP_SUMMARY:-}" ]; then
exit 0
fi
{
echo "## Agent Ready"
echo
echo '```text'
if [ -n "${{ inputs.config }}" ]; then
node "$GITHUB_ACTION_PATH/bin/agent-ready.mjs" doctor --config "${{ inputs.config }}"
else
node "$GITHUB_ACTION_PATH/bin/agent-ready.mjs" doctor
fi
echo '```'
echo
if [ -n "${{ inputs.config }}" ]; then
node "$GITHUB_ACTION_PATH/bin/agent-ready.mjs" matrix --config "${{ inputs.config }}" --format markdown
else
node "$GITHUB_ACTION_PATH/bin/agent-ready.mjs" matrix --format markdown
fi
echo
if [ -n "${{ inputs.config }}" ]; then
node "$GITHUB_ACTION_PATH/bin/agent-ready.mjs" report --config "${{ inputs.config }}" --format markdown
else
node "$GITHUB_ACTION_PATH/bin/agent-ready.mjs" report --format markdown
fi
} >> "$GITHUB_STEP_SUMMARY"
- name: Annotate agent-ready findings
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
if [ -n "${{ inputs.config }}" ]; then
node "$GITHUB_ACTION_PATH/bin/agent-ready.mjs" annotations --config "${{ inputs.config }}"
else
node "$GITHUB_ACTION_PATH/bin/agent-ready.mjs" annotations
fi
- name: Comment on pull request
if: ${{ inputs.comment == 'true' && github.event_name == 'pull_request' }}
shell: bash
working-directory: ${{ inputs.working-directory }}
env:
GH_TOKEN: ${{ inputs.github-token }}
GH_REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
if ! command -v gh >/dev/null 2>&1; then
echo "agent-ready comment skipped: GitHub CLI is not available."
exit 0
fi
if [ -z "${GH_TOKEN:-}" ]; then
echo "agent-ready comment skipped: github-token is empty."
exit 0
fi
body_file="$(mktemp)"
{
echo "<!-- agent-ready-comment -->"
echo
if [ -n "${{ inputs.config }}" ]; then
node "$GITHUB_ACTION_PATH/bin/agent-ready.mjs" comment --config "${{ inputs.config }}"
else
node "$GITHUB_ACTION_PATH/bin/agent-ready.mjs" comment
fi
} > "$body_file"
existing_id="$(gh api "repos/$GH_REPO/issues/$PR_NUMBER/comments" --jq '.[] | select(.body | contains("<!-- agent-ready-comment -->")) | .id' | head -n 1)"
if [ -n "$existing_id" ]; then
gh api --method PATCH "repos/$GH_REPO/issues/comments/$existing_id" -f body="$(cat "$body_file")" >/dev/null
else
gh api --method POST "repos/$GH_REPO/issues/$PR_NUMBER/comments" -f body="$(cat "$body_file")" >/dev/null
fi
- name: Score agent readiness
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
if [ -n "${{ inputs.config }}" ]; then
node "$GITHUB_ACTION_PATH/bin/agent-ready.mjs" score --config "${{ inputs.config }}" --fail-under "${{ inputs.fail-under }}"
else
node "$GITHUB_ACTION_PATH/bin/agent-ready.mjs" score --fail-under "${{ inputs.fail-under }}"
fi