forked from mgifford/ACCESSIBILITY.md
-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (97 loc) · 4.08 KB
/
create-agent-issues.yml
File metadata and controls
106 lines (97 loc) · 4.08 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
name: Create Agent Issues
# Creates GitHub Issues from the structured proposals in .github/issue-proposals/.
# Inspired by the pattern used in mgifford/open-scans#95:
# https://github.com/mgifford/open-scans/pull/95
#
# This workflow runs automatically when changes are pushed to the main branch,
# and can also be triggered manually via the Actions tab.
# Idempotency checks prevent duplicate issues from being created on re-runs.
#
# Prerequisites: The 'enhancement' label must exist (created by default on new
# GitHub repositories). The workflow will create 'ai-agent', 'ci-cd', and
# 'documentation' labels automatically if they are missing.
on:
workflow_dispatch:
push:
branches:
- main
permissions:
issues: write
contents: read
jobs:
create-issues:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Ensure required labels exist
uses: actions/github-script@v7
with:
script: |
const labels = [
{ name: 'ai-agent', color: '0052cc', description: 'AI agent workflow or tooling' },
{ name: 'ci-cd', color: 'e4e669', description: 'CI/CD pipeline related' },
{ name: 'documentation', color: '0075ca', description: 'Improvements or additions to documentation' },
];
for (const label of labels) {
try {
await github.rest.issues.getLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: label.name,
});
} catch (e) {
if (e.status === 404) {
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
...label,
});
console.log(`Created label: ${label.name}`);
} else {
throw e;
}
}
}
- name: Create issues from proposals
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const proposals = [
{
file: '.github/issue-proposals/001-copilot-agent-accessibility-md-bootstrap.md',
title: 'Add example: GitHub Copilot coding agent to bootstrap ACCESSIBILITY.md for new projects',
labels: ['enhancement', 'ai-agent', 'documentation'],
},
{
file: '.github/issue-proposals/002-copilot-agent-remediation-workflow.md',
title: 'Add example: GitHub Copilot agent workflow for automated accessibility issue remediation',
labels: ['enhancement', 'ai-agent', 'ci-cd'],
},
{
file: '.github/issue-proposals/003-agents-md-copilot-agent-mode-guide.md',
title: 'Add guide: Structuring AGENTS.md for GitHub Copilot agent mode (WCAG-grounded code generation)',
labels: ['enhancement', 'ai-agent', 'documentation'],
},
];
const stripFrontmatter = (raw) => raw.replace(/^---\n[\s\S]*?\n---\n/, '');
for (const [i, proposal] of proposals.entries()) {
const search = await github.rest.search.issuesAndPullRequests({
q: `repo:${context.repo.owner}/${context.repo.repo} is:issue in:title "${proposal.title}"`,
});
if (search.data.total_count > 0) {
console.log(`Issue ${i + 1} already exists, skipping`);
} else {
const raw = fs.readFileSync(proposal.file, 'utf8');
const body = stripFrontmatter(raw);
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: proposal.title,
labels: proposal.labels,
body,
});
console.log(`Issue ${i + 1} created successfully`);
}
}