-
Notifications
You must be signed in to change notification settings - Fork 8
146 lines (114 loc) · 5.13 KB
/
update-runtime-spec.yml
File metadata and controls
146 lines (114 loc) · 5.13 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
name: Update Runtime Specification
on:
schedule:
# Run daily at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch: # Allow manual triggering
jobs:
update-runtime-spec:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Update runtime specification
run: |
node -e "
const fs = require('fs');
const path = require('path');
async function fetchRuntimes() {
try {
const response = await fetch('https://api.checklyhq.com/v1/runtimes');
if (!response.ok) {
throw new Error(\`HTTP error! status: \${response.status}\`);
}
return await response.json();
} catch (error) {
console.error('Error fetching runtimes:', error);
process.exit(1);
}
}
function generateRuntimeContent(runtimes) {
let content = '';
runtimes.forEach(runtime => {
// Skip BETA runtimes (equivalent to Hugo's \`{{ if ne .stage \"BETA\" }}\`)
if (runtime.stage === 'BETA') {
return;
}
// Add runtime name header
content += \`### \\\`\${runtime.name}\\\`\\n\`;
// Add deprecated notice if applicable
if (runtime.stage === 'DEPRECATED') {
content += \`(\${runtime.stage})\\n\\n\`;
content += \`This runtime will be available until \${runtime.runtimeEndOfLife}. Please update your checks' runtimes and account settings to avoid failures due to automatic change to the next supported runtime.\\n\\n\`;
} else {
content += '\\n';
}
// Add Node.js version
content += \`Node.js Version: \\\`\${runtime.nodeJsVersion}\\\`\\n\\n\`;
// Add description
content += \`\${runtime.description}\\n\\n\`;
// Add dependencies
if (runtime.dependencies) {
Object.entries(runtime.dependencies).forEach(([key, value]) => {
content += \`- [\${key}](https://npmjs.com/package/\${key}/v/\${value}) \${value}\\n\`;
});
}
content += '\\n';
});
return content;
}
async function updateRuntimeSpecFile(generatedContent) {
const filePath = path.join(process.cwd(), 'platform/runtimes/runtime-specification.mdx');
try {
const fileContent = fs.readFileSync(filePath, 'utf8');
// Find where to insert the generated content (after \"## NPM packages\" section)
const insertionPoint = fileContent.indexOf('> and \`mocha\`.\\n\\n');
if (insertionPoint === -1) {
console.error('Could not find insertion point in the file');
process.exit(1);
}
const beforeInsertion = fileContent.substring(0, insertionPoint + '> and \`mocha\`.\\n\\n'.length);
// Create new content with updated runtimes
const newContent = beforeInsertion + '\\n' + generatedContent;
fs.writeFileSync(filePath, newContent);
console.log('Runtime specification updated successfully!');
} catch (error) {
console.error('Error updating file:', error);
process.exit(1);
}
}
async function main() {
console.log('Fetching runtime data...');
const runtimes = await fetchRuntimes();
console.log(\`Found \${runtimes.length} runtimes\`);
console.log('Generating content...');
const generatedContent = generateRuntimeContent(runtimes);
console.log('Updating runtime specification file...');
await updateRuntimeSpecFile(generatedContent);
}
main().catch(console.error);
"
- name: Check for changes
id: verify-changed-files
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Commit and push changes
if: steps.verify-changed-files.outputs.changed == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add platform/runtimes/runtime-specification.mdx
git commit -m "🤖 Update runtime specification
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>"
git push