Skip to content

Commit

Permalink
update planets validation/update actions
Browse files Browse the repository at this point in the history
update planets/index.json

use main planet registry
  • Loading branch information
eseiker committed Dec 4, 2024
1 parent e6e23fe commit bae6600
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 115 deletions.
25 changes: 25 additions & 0 deletions .github/scripts/validate-planets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as path from "jsr:@std/path";

import Ajv2019 from "npm:ajv/dist/2019.js";
import addFormats from "npm:ajv-formats";

const baseUrl =
"https://planetarium.github.io/json-schema/NineChronicles/2024-12/";
const fetchJsonSchema = async (name) =>
await (await fetch(path.join(baseUrl, `/${name}.schema.json`))).json();

const ajv = new Ajv2019({ allErrors: true });
addFormats(ajv);

ajv.addSchema(await fetchJsonSchema("PlanetSpec"), "PlanetSpec.schema.json");

const validate = ajv.compile(await fetchJsonSchema("PlanetRegistry"));

for (const filename of Deno.args) {
console.log(`validating ${filename}`);
const valid = validate(JSON.parse(await Deno.readTextFile(filename)));
if (!valid) {
console.error(`Error validating ${filename}:`, validate.errors);
Deno.exit(1);
}
}
17 changes: 0 additions & 17 deletions .github/workflows/planets.yaml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/update-planets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Update planets config

on:
pull_request:
paths:
- planets/index.json
branches:
- main
types:
- closed

jobs:
validate-planets-config:
if: github.event.pull_request.merged == true
uses: ./.github/workflows/validate-planets.yaml
update-planets-config:
needs: [validate-planets-config]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- run: |
aws s3 cp planets/index.json s3://planets.nine-chronicles.com/planets/index.json
aws cloudfront create-invalidation --distribution-id EP1JH2OWQMIKM --paths "/*"
17 changes: 17 additions & 0 deletions .github/workflows/validate-planets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Validate planets config

on:
workflow_call:
pull_request:
paths:
- planets/index.json

jobs:
validate-planets-config:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- run: deno -A .github/scripts/validate-planets.js planets/index.json
8 changes: 7 additions & 1 deletion planets/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@
"dp.gql": ["http://odin-dp.9c.gg/graphql"],
"9cscan.rest": ["https://api.9cscan.com"],
"headless.gql": [
"https://odin-rpc-1.nine-chronicles.com/graphql",
"https://odin-rpc-2.nine-chronicles.com/graphql",
"http://sgp-nc-1.ninodes.com/graphql",
"http://sgp-nc-2.ninodes.com/graphql",
"http://ash-nc-1.ninodes.com/graphql",
"http://phx-nc-1.ninodes.com/graphql",
"http://nld-nc-1.ninodes.com/graphql"
],
"headless.grpc": [
"http://odin-rpc-1.nine-chronicles.com:31238",
"http://odin-rpc-2.nine-chronicles.com:31238",
"http://sgp-nc-1.ninodes.com:31238",
"http://sgp-nc-2.ninodes.com:31238",
"http://ash-nc-1.ninodes.com:31238",
"http://phx-nc-1.ninodes.com:31238",
"http://nld-nc-1.ninodes.com:31238"
Expand Down Expand Up @@ -126,4 +132,4 @@
}
}
}
]
]
97 changes: 0 additions & 97 deletions planets/schema.json

This file was deleted.

0 comments on commit bae6600

Please sign in to comment.