Repository navigation
153 lines (134 loc) · 4.95 KB
/
Copy pathmeta.yml
File metadata and controls
153 lines (134 loc) · 4.95 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
---
name: Meta Agent
on:
workflow_dispatch:
pull_request:
branches: [develop]
paths:
- "**/*.md"
- ".github/labels.yml"
- ".github/labeler.yml"
- ".github/issue-types.yml"
- ".github/agents/**"
push:
branches: [develop]
paths:
- "**/*.md"
- ".github/labels.yml"
- ".github/labeler.yml"
- ".github/issue-types.yml"
- ".github/agents/**"
schedule:
- cron: "0 3 * * 1" # weekly metrics roll-up (Mon 03:00 UTC)
concurrency:
group: "meta-${{ github.ref }}"
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
jobs:
front-matter-validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version-file: ".nvmrc"
- name: Install dependencies
run: npm ci
- name: Validate frontmatter freshness
run: |
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
BASE_REF="${{ github.event.pull_request.base.sha }}"
HEAD_REF="${{ github.event.pull_request.head.sha }}"
elif [ "${GITHUB_EVENT_NAME}" = "push" ]; then
BASE_REF="${{ github.event.before }}"
HEAD_REF="${{ github.sha }}"
else
BASE_REF="HEAD~1"
HEAD_REF="${{ github.sha }}"
fi
npm run validate:frontmatter:changed -- --base "$BASE_REF" --head "$HEAD_REF"
lint-and-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version-file: ".nvmrc"
- name: Install dependencies
run: npm ci
- name: Lint changed Markdown
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before || 'HEAD~1' }}
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: node scripts/validate-markdown-lint.js
- name: Collect Link Targets
id: link_targets
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before || 'HEAD~1' }}
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: node scripts/collect-link-targets.js >> "$GITHUB_OUTPUT"
- name: Check Links
if: steps.link_targets.outputs.files != ''
uses: lycheeverse/lychee-action@v2
with:
args: --no-progress --verbose --config lychee.toml ${{ steps.link_targets.outputs.files }}
apply-meta:
if: ${{ github.event_name != 'pull_request' }}
needs: [front-matter-validate, lint-and-links]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version-file: ".nvmrc"
- name: Install dependencies
run: npm ci
- name: Run Meta Agent
env:
META_SKIP_README: "true"
run: |
node scripts/agents/meta.agent.js
- name: Update Metrics Snapshot
run: |
mkdir -p .github/metrics
# Read metrics from meta agent output (meta-metrics.json)
if [ -f .github/metrics/meta-metrics.json ]; then
node -e "
const fs = require('fs');
const m = JSON.parse(fs.readFileSync('.github/metrics/meta-metrics.json', 'utf8'));
m.ts = new Date().toISOString();
fs.writeFileSync('.github/metrics/meta.json', JSON.stringify(m, null, 2));
const logLine = \`| \${m.ts} | coverage:\${m.coverage} | changes:\${m.changes} | errors:\${m.errors} | optouts:\${m.optouts} |\n\`;
fs.appendFileSync('.github/metrics/meta-log.md', logLine);
"
else
echo "Warning: .github/metrics/meta-metrics.json not found. Writing zeroed metrics."
node -e "
const fs = require('fs');
let m = { ts: new Date().toISOString(), coverage: 0, changes: 0, errors: 0, optouts: 0 };
fs.writeFileSync('.github/metrics/meta.json', JSON.stringify(m, null, 2));
const logLine = \`| \${m.ts} | coverage:0 | changes:0 | errors:0 | optouts:0 |\n\`;
fs.appendFileSync('.github/metrics/meta-log.md', logLine);
"
fi
# develop requires the "Validate PR Template" status check, which only
# runs for pull_request events — a direct `git push` to develop can
# never satisfy it (see lightspeedwp/.github#1070). Route the change
# through a PR instead, with auto-merge so this stays hands-off.
- name: Open or update automation PR
env:
GH_TOKEN: ${{ github.token }}
run: node scripts/handle-meta-agent-pr.js