-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (48 loc) · 1.96 KB
/
ci.yml
File metadata and controls
61 lines (48 loc) · 1.96 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
# CI workflow for the github-workflows repository itself
# Tests the reusable workflows by validating their syntax
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install js-yaml
run: npm install js-yaml
- name: Validate workflow syntax
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');
const workflowDir = '.github/workflows';
const files = fs.readdirSync(workflowDir).filter(f => f.endsWith('.yml') || f.endsWith('.yaml'));
let errors = [];
for (const file of files) {
const filePath = path.join(workflowDir, file);
const content = fs.readFileSync(filePath, 'utf8');
try {
yaml.load(content);
console.log(`✓ ${file}: valid YAML`);
} catch (e) {
errors.push(`${file}: ${e.message}`);
console.log(`✗ ${file}: ${e.message}`);
}
}
if (errors.length > 0) {
core.setFailed(`Workflow validation failed:\n${errors.join('\n')}`);
}
- name: Check required fields
run: |
echo "Checking docker-build.yml..."
yq eval '.on.workflow_call.outputs.build_id' .github/workflows/docker-build.yml
yq eval '.on.workflow_call.outputs.metadata_url' .github/workflows/docker-build.yml
echo "Checking k8s-promote.yml..."
yq eval '.on.workflow_call.inputs.environment' .github/workflows/k8s-promote.yml
yq eval '.on.workflow_call.inputs.build_id' .github/workflows/k8s-promote.yml
echo "✓ All required fields present"