diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19ba24b..e4317cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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: >- diff --git a/.github/workflows/regions.yml b/.github/workflows/regions.yml new file mode 100644 index 0000000..b18205a --- /dev/null +++ b/.github/workflows/regions.yml @@ -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/script-action@v0.2 + 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);