Skip to content

Commit cbfa4b0

Browse files
Actually continuously integrate
1 parent e743367 commit cbfa4b0

File tree

337 files changed

+54967
-65
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

337 files changed

+54967
-65
lines changed

.github/actions/format/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: Format YAML files
2+
inputs:
3+
token:
4+
required: true
5+
default: "${{ github.token }}"
6+
runs:
7+
using: node20
8+
main: index.js

.github/actions/format/index.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const core = require("@actions/core")
2+
const fs = require("fs")
3+
const yaml = require("js-yaml")
4+
5+
try {
6+
const yamlFiles = fs.readdirSync("./").filter(file => file.endsWith(".yaml"))
7+
format(yamlFiles)
8+
} catch (error) {
9+
core.setFailed(error.message)
10+
}
11+
12+
function format(yamlFiles) {
13+
yamlFiles.forEach(file => {
14+
const content = fs.readFileSync(file)
15+
16+
let data = yaml.load(content)
17+
data = consistent(data)
18+
data = sort(data)
19+
20+
const formattedContent = yaml.dump(data, {quotingType: '"', lineWidth: -1})
21+
fs.writeFileSync(file, formattedContent)
22+
})
23+
}
24+
25+
function consistent(data) { // one-record subdomains might not be an array
26+
for (const key in data) {
27+
if (!Array.isArray(data[key])) {
28+
const array = [data[key]]
29+
data[key] = array
30+
}
31+
}
32+
33+
return data
34+
}
35+
36+
function sort(subdomains) {
37+
const sortedSubdomains = {}
38+
Object.keys(subdomains).sort().forEach(key => {
39+
sortedSubdomains[key] = subdomains[key]
40+
})
41+
42+
for (const subdomain in sortedSubdomains) {
43+
const records = sortedSubdomains[subdomain]
44+
for (const record in records) {
45+
const sortedOptions = {}
46+
Object.keys(records[record]).sort().forEach(option => {
47+
sortedOptions[option] = sortedSubdomains[subdomain][record][option]
48+
})
49+
sortedSubdomains[subdomain][record] = sortedOptions
50+
}
51+
}
52+
53+
return sortedSubdomains
54+
}

.github/actions/format/node_modules/.bin/js-yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/format/node_modules/.bin/uuid

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/format/node_modules/.package-lock.json

Lines changed: 76 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/format/node_modules/@actions/core/LICENSE.md

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)