Skip to content

Commit ad9c85d

Browse files
authored
feat: use @octokit/openapi (#197)
BREAKING CHANGE: The `:param` path notion has been replaced with `{param}` in `Endpoints` to align with GitHub's documentation and to conform to [rfc6570](https://tools.ietf.org/html/rfc6570)
1 parent 4dfee5a commit ad9c85d

File tree

13 files changed

+12326
-79315
lines changed

13 files changed

+12326
-79315
lines changed
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Release notification
2+
on:
3+
release:
4+
types:
5+
- published
6+
7+
jobs:
8+
notify:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: gr2m/release-notifier-action@v1
12+
with:
13+
app_id: ${{ secrets.RELEASE_NOTIFIER_APP_ID }}
14+
private_key: ${{ secrets.RELEASE_NOTIFIER_APP_PRIVATE_KEY }}

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
- run: npm run build
2121
- run: npx semantic-release
2222
env:
23-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
23+
GITHUB_TOKEN: ${{ secrets.OCTOKITBOT_PAT }}
24+
NPM_TOKEN: ${{ secrets.OCTOKITBOT_NPM_TOKEN }}
2525
- run: npm run docs
2626
- uses: maxheld83/ghpages@master
2727
env:

.github/workflows/update.yml

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
name: Update
22
on:
33
repository_dispatch:
4-
types: [github-openapi-release]
4+
# https://github.com/octokit/openapi-types.ts/blob/main/.github/workflows/release-notification.yml
5+
types: [octokit/openapi-types release]
56

67
workflow_dispatch:
7-
inputs:
8-
version:
9-
description: "Version of https://www.npmjs.com/package/@github/openapi"
10-
required: true
118

129
jobs:
1310
update_routes:
1411
runs-on: ubuntu-latest
15-
if: github.event_name == 'workflow_dispatch' || github.event.client_payload.action == 'published'
1612
steps:
1713
- uses: actions/checkout@v2
1814
- uses: actions/setup-node@v1
@@ -21,14 +17,13 @@ jobs:
2117
# try checking out routes-update branch. Ignore error if it does not exist
2218
- run: git checkout routes-update || true
2319
- run: npm ci
24-
- run: npm run update-endpoints
20+
- run: npm install @octokit/openapi-types@latest
2521
if: github.event_name == 'repository_dispatch'
26-
env:
27-
VERSION: ${{ github.event.client_payload.release.tag_name }}
22+
- run: node -e "console.log('::set-output name=version::' + require('@octokit/openapi-types/package').octokit['openapi-version'])"
23+
id: openapi_types
2824
- run: npm run update-endpoints
29-
if: github.event_name == 'workflow_dispatch'
3025
env:
31-
VERSION: ${{ github.event.inputs.version }}
26+
VERSION: ${{ steps.openapi_types.outputs.version }}
3227
- name: Create Pull Request
3328
uses: gr2m/[email protected]
3429
env:

package-lock.json

+1,839-2,079
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
},
77
"description": "Shared TypeScript definitions for Octokit projects",
88
"dependencies": {
9+
"@octokit/openapi-types": "^1.2.0",
910
"@types/node": ">= 8"
1011
},
1112
"scripts": {
@@ -17,7 +18,8 @@
1718
"test": "npx tsc --noEmit --declaration --noUnusedLocals src/index.ts test.ts",
1819
"update-endpoints": "npm-run-all update-endpoints:*",
1920
"update-endpoints:fetch-json": "node scripts/update-endpoints/fetch-json",
20-
"update-endpoints:typescript": "node scripts/update-endpoints/typescript"
21+
"update-endpoints:typescript": "node scripts/update-endpoints/typescript",
22+
"update-endpoints:package": "node scripts/update-endpoints/package"
2123
},
2224
"repository": "https://github.com/octokit/types.ts",
2325
"keywords": [
@@ -39,6 +41,7 @@
3941
"json-schema-to-typescript": "^10.0.0",
4042
"lodash.set": "^4.3.2",
4143
"npm-run-all": "^4.1.5",
44+
"openapi-typescript": "^2.3.1",
4245
"pascal-case": "^3.1.1",
4346
"prettier": "^2.0.0",
4447
"semantic-release": "^17.0.0",
@@ -83,5 +86,8 @@
8386
}
8487
]
8588
]
89+
},
90+
"octokit": {
91+
"openapi-version": "1.0.1"
8692
}
8793
}

scripts/update-endpoints/fetch-json.js

+2-19
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,18 @@ const version = process.env.VERSION.replace(/^v/, "");
1313
const QUERY = `
1414
query ($version: String!, $ignoreChangesBefore: String!) {
1515
endpoints(version: $version, ignoreChangesBefore: $ignoreChangesBefore) {
16-
name
17-
scope(format: CAMELCASE)
18-
id(format: CAMELCASE)
1916
method
2017
url
2118
documentationUrl
2219
parameters {
2320
alias
24-
allowNull
2521
deprecated
26-
description
27-
enum
2822
in
2923
name
30-
type
31-
required
3224
}
3325
previews(required: true) {
3426
name
3527
}
36-
headers {
37-
name
38-
value
39-
required
40-
}
41-
responses {
42-
code
43-
description
44-
schema
45-
}
4628
renamed {
4729
note
4830
}
@@ -53,7 +35,8 @@ main();
5335

5436
async function main() {
5537
const { endpoints } = await graphql(QUERY, {
56-
url: "https://github-openapi-graphql-server.vercel.app/api/graphql",
38+
// url: "https://github-openapi-graphql-server.vercel.app/api/graphql",
39+
url: "http://localhost:3000/api/graphql",
5740
version,
5841
ignoreChangesBefore: "2020-06-10",
5942
});

0 commit comments

Comments
 (0)