Send X-GitHub-Api-Version when calling [GitHub] v3 API (#8669)

* send X-GitHub-Api-Version when calling GitHub v3 API

* TODO: invesitgate

* read baseUrl from config.service.baseUri

* add workflow to check for new GH api releases on schedule

* format config/default.yml to match yaml.dump() format

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
chris48s
2022-12-31 15:56:04 +00:00
committed by GitHub
parent 8be87554d6
commit c3d08f7f8b
7 changed files with 62 additions and 11 deletions

View File

@@ -0,0 +1,19 @@
import fs from 'fs/promises'
import got from 'got'
import yaml from 'js-yaml'
const resp = await got('https://api.github.com/versions').json()
const latestDate = resp.sort()[resp.length - 1]
const config = yaml.load(await fs.readFile('./config/default.yml', 'utf8'))
if (latestDate === config.public.services.github.restApiVersion) {
console.log("We're already using the latest version. No change needed.")
process.exit(0)
}
config.public.services.github.restApiVersion = latestDate
await fs.writeFile(
'./config/default.yml',
yaml.dump(config, { forceQuotes: true })
)