@@ -14,6 +14,10 @@ permissions:
1414 contents : read
1515 pull-requests : write
1616
17+ concurrency :
18+ group : ${{ github.workflow }}-${{ github.event.pull_request.number }}
19+ cancel-in-progress : true
20+
1721jobs :
1822 validate-agent :
1923 name : Verify Agent File
@@ -28,44 +32,42 @@ jobs:
2832 run : |
2933 # Find new/modified .md files in agents/ or community-agents/
3034 AGENTS=$(find agents community-agents -name '*.md' 2>/dev/null || true)
31-
35+
3236 if [ -z "$AGENTS" ]; then
3337 echo "found=false" >> "$GITHUB_OUTPUT"
3438 exit 0
3539 fi
36-
40+
3741 echo "found=true" >> "$GITHUB_OUTPUT"
3842 FIRST=$(echo "$AGENTS" | head -1)
3943 echo "file=$FIRST" >> "$GITHUB_OUTPUT"
40- CHECK_FILE="/tmp/capstone-agent.md"
41- sed '1s/^\xEF\xBB\xBF//' "$FIRST" > "$CHECK_FILE"
42-
44+
4345 ERRORS=""
44-
46+
4547 # Check YAML frontmatter exists (starts with ---)
46- if head -1 "$CHECK_FILE " | grep -q '^---'; then
48+ if head -1 "$FIRST " | grep -q '^---'; then
4749 echo "has_frontmatter=true" >> "$GITHUB_OUTPUT"
4850 else
4951 echo "has_frontmatter=false" >> "$GITHUB_OUTPUT"
5052 ERRORS="missing YAML frontmatter"
5153 fi
52-
54+
5355 # Check for responsibilities section
54- if grep -qi '## responsibilities\|## what this agent does' "$CHECK_FILE "; then
56+ if grep -qi '## responsibilities\|## what this agent does' "$FIRST "; then
5557 echo "has_responsibilities=true" >> "$GITHUB_OUTPUT"
5658 else
5759 echo "has_responsibilities=false" >> "$GITHUB_OUTPUT"
5860 ERRORS="$ERRORS${ERRORS:+, }missing responsibilities section"
5961 fi
60-
62+
6163 # Check for guardrails section
62- if grep -qi '## guardrails\|## limitations\|## boundaries' "$CHECK_FILE "; then
64+ if grep -qi '## guardrails\|## limitations\|## boundaries' "$FIRST "; then
6365 echo "has_guardrails=true" >> "$GITHUB_OUTPUT"
6466 else
6567 echo "has_guardrails=false" >> "$GITHUB_OUTPUT"
6668 ERRORS="$ERRORS${ERRORS:+, }missing guardrails section"
6769 fi
68-
70+
6971 echo "errors=$ERRORS" >> "$GITHUB_OUTPUT"
7072
7173 - name : Post result
@@ -105,13 +107,70 @@ jobs:
105107 'Excellent capstone work!'
106108 ].join('\n');
107109 }
110+ const MARKER = '## Challenge 16:';
108111 try {
109- await github.rest.issues.createComment ({
112+ const { data: comments } = await github.rest.issues.listComments ({
110113 owner: context.repo.owner,
111114 repo: context.repo.repo,
112- issue_number: context.issue.number,
113- body
115+ issue_number: context.issue.number
114116 });
117+ const existing = comments.find(c => c.user.type === 'Bot' && c.body.includes(MARKER));
118+ if (existing) {
119+ await github.rest.issues.updateComment({
120+ owner: context.repo.owner,
121+ repo: context.repo.repo,
122+ comment_id: existing.id,
123+ body
124+ });
125+ } else {
126+ await github.rest.issues.createComment({
127+ owner: context.repo.owner,
128+ repo: context.repo.repo,
129+ issue_number: context.issue.number,
130+ body
131+ });
132+ }
115133 } catch (error) {
116134 console.error('Could not post Challenge 16 result:', error.message);
117135 }
136+
137+ - name : Post workflow error notice
138+ if : failure()
139+ uses : actions/github-script@v7
140+ with :
141+ script : |
142+ const MARKER = '## Challenge 16:';
143+ const body = [
144+ '## Challenge 16: Check could not complete',
145+ '',
146+ 'The automated agent file check ran into an unexpected error. Your work is not affected.',
147+ 'Keep going and ask your facilitator, or mention @facilitator in a comment.',
148+ '',
149+ '---',
150+ '*Automated message from Learning Room Bot.*'
151+ ].join('\n');
152+ try {
153+ const { data: comments } = await github.rest.issues.listComments({
154+ owner: context.repo.owner,
155+ repo: context.repo.repo,
156+ issue_number: context.issue.number
157+ });
158+ const existing = comments.find(c => c.user.type === 'Bot' && c.body.includes(MARKER));
159+ if (existing) {
160+ await github.rest.issues.updateComment({
161+ owner: context.repo.owner,
162+ repo: context.repo.repo,
163+ comment_id: existing.id,
164+ body
165+ });
166+ } else {
167+ await github.rest.issues.createComment({
168+ owner: context.repo.owner,
169+ repo: context.repo.repo,
170+ issue_number: context.issue.number,
171+ body
172+ });
173+ }
174+ } catch (err) {
175+ console.error('Could not post error notice:', err.message);
176+ }
0 commit comments