Skip to content

Commit

Permalink
Check for new Fly.io regions
Browse files Browse the repository at this point in the history
  • Loading branch information
silverlyra committed May 29, 2024
1 parent b0b7c54 commit 5645073
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: moonrepo/setup-rust@v1
with:
components: rustfmt
Expand All @@ -21,7 +21,7 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: moonrepo/setup-rust@v1
with:
components: clippy
Expand All @@ -36,7 +36,7 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: moonrepo/setup-rust@v1
- name: Run tests
run: >-
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/regions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Check for new regions

on:
pull_request:
paths: src/region.rs
workflow_dispatch:
schedule:
- cron: >-
15 15 * * *
jobs:
check:
name: Check
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- name: Get current regions
run: >
curl 'https://app.fly.io/graphql' -H 'Accept: application/json' -H 'Content-Type: application/json' --data-binary '{"query":"{\n platform {\n regions {\n code\n name\n }\n }\n}"}'
| jq '.data.platform.regions'
> "${RUNNER_TEMP}/regions.current.json"
- uses: actions/checkout@v4
- uses: moonrepo/setup-rust@v1
- name: Get defined regions
run: >-
cargo run --example regions | awk '{print $1}' | sort
> "${RUNNER_TEMP}/regions.defined.txt"
- name: Compare
uses: silverlyra/[email protected]
with:
script: |
const read = (filename) => fs.readFile(path.join(env.RUNNER_TEMP, filename), 'utf-8');
const current = JSON.parse(await read('regions.current.json'));
const defined = new Set((await read('regions.defined.txt')).split('\n').filter(Boolean));
let ok = true;
for (const { code, name } of current) {
console.log(`${code}\t${name}`);
if (!defined.has(code)) {
ok = false;
console.log(` not defined in Flytrap`);
}
}
if (!ok) process.exit(1);

0 comments on commit 5645073

Please sign in to comment.