Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actually continuously integrate #1129

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions .github/actions/format/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Format YAML files
inputs:
token:
required: true
default: "${{ github.token }}"
runs:
using: node20
main: index.js
54 changes: 54 additions & 0 deletions .github/actions/format/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const core = require("@actions/core")
const fs = require("fs")
const yaml = require("js-yaml")

try {
const yamlFiles = fs.readdirSync("./").filter(file => file.endsWith(".yaml"))
format(yamlFiles)
} catch (error) {
core.setFailed(error.message)
}

function format(yamlFiles) {
yamlFiles.forEach(file => {
const content = fs.readFileSync(file)

let data = yaml.load(content)
data = consistent(data)
data = sort(data)

const formattedContent = yaml.dump(data, {quotingType: '"', lineWidth: -1})
fs.writeFileSync(file, formattedContent)
})
}

function consistent(data) { // one-record subdomains might not be an array
for (const key in data) {
if (!Array.isArray(data[key])) {
const array = [data[key]]
data[key] = array
}
}

return data
}
northeastprince marked this conversation as resolved.
Show resolved Hide resolved

function sort(subdomains) {
const sortedSubdomains = {}
Object.keys(subdomains).sort().forEach(key => {
sortedSubdomains[key] = subdomains[key]
})

for (const subdomain in sortedSubdomains) {
const records = sortedSubdomains[subdomain]
for (const record in records) {
const sortedOptions = {}
Object.keys(records[record]).sort().forEach(option => {
sortedOptions[option] = sortedSubdomains[subdomain][record][option]
})
sortedSubdomains[subdomain][record] = sortedOptions
}
}

return sortedSubdomains
}
1 change: 1 addition & 0 deletions .github/actions/format/node_modules/.bin/js-yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .github/actions/format/node_modules/.bin/uuid

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions .github/actions/format/node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading