Skip to content

Commit

Permalink
feat: use @octokit/openapi (#197)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
gr2m authored Nov 30, 2020
1 parent 4dfee5a commit ad9c85d
Show file tree
Hide file tree
Showing 13 changed files with 12,326 additions and 79,315 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/release-notification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release notification
on:
release:
types:
- published

jobs:
notify:
runs-on: ubuntu-latest
steps:
- uses: gr2m/release-notifier-action@v1
with:
app_id: ${{ secrets.RELEASE_NOTIFIER_APP_ID }}
private_key: ${{ secrets.RELEASE_NOTIFIER_APP_PRIVATE_KEY }}
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
- run: npm run build
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.OCTOKITBOT_PAT }}
NPM_TOKEN: ${{ secrets.OCTOKITBOT_NPM_TOKEN }}
- run: npm run docs
- uses: maxheld83/ghpages@master
env:
Expand Down
17 changes: 6 additions & 11 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
name: Update
on:
repository_dispatch:
types: [github-openapi-release]
# https://github.com/octokit/openapi-types.ts/blob/main/.github/workflows/release-notification.yml
types: [octokit/openapi-types release]

workflow_dispatch:
inputs:
version:
description: "Version of https://www.npmjs.com/package/@github/openapi"
required: true

jobs:
update_routes:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || github.event.client_payload.action == 'published'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand All @@ -21,14 +17,13 @@ jobs:
# try checking out routes-update branch. Ignore error if it does not exist
- run: git checkout routes-update || true
- run: npm ci
- run: npm run update-endpoints
- run: npm install @octokit/openapi-types@latest
if: github.event_name == 'repository_dispatch'
env:
VERSION: ${{ github.event.client_payload.release.tag_name }}
- run: node -e "console.log('::set-output name=version::' + require('@octokit/openapi-types/package').octokit['openapi-version'])"
id: openapi_types
- run: npm run update-endpoints
if: github.event_name == 'workflow_dispatch'
env:
VERSION: ${{ github.event.inputs.version }}
VERSION: ${{ steps.openapi_types.outputs.version }}
- name: Create Pull Request
uses: gr2m/create-or-update-pull-request-action@v1.x
env:
Expand Down
3,918 changes: 1,839 additions & 2,079 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"description": "Shared TypeScript definitions for Octokit projects",
"dependencies": {
"@octokit/openapi-types": "^1.2.0",
"@types/node": ">= 8"
},
"scripts": {
Expand All @@ -17,7 +18,8 @@
"test": "npx tsc --noEmit --declaration --noUnusedLocals src/index.ts test.ts",
"update-endpoints": "npm-run-all update-endpoints:*",
"update-endpoints:fetch-json": "node scripts/update-endpoints/fetch-json",
"update-endpoints:typescript": "node scripts/update-endpoints/typescript"
"update-endpoints:typescript": "node scripts/update-endpoints/typescript",
"update-endpoints:package": "node scripts/update-endpoints/package"
},
"repository": "https://github.com/octokit/types.ts",
"keywords": [
Expand All @@ -39,6 +41,7 @@
"json-schema-to-typescript": "^10.0.0",
"lodash.set": "^4.3.2",
"npm-run-all": "^4.1.5",
"openapi-typescript": "^2.3.1",
"pascal-case": "^3.1.1",
"prettier": "^2.0.0",
"semantic-release": "^17.0.0",
Expand Down Expand Up @@ -83,5 +86,8 @@
}
]
]
},
"octokit": {
"openapi-version": "1.0.1"
}
}
21 changes: 2 additions & 19 deletions scripts/update-endpoints/fetch-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,18 @@ const version = process.env.VERSION.replace(/^v/, "");
const QUERY = `
query ($version: String!, $ignoreChangesBefore: String!) {
endpoints(version: $version, ignoreChangesBefore: $ignoreChangesBefore) {
name
scope(format: CAMELCASE)
id(format: CAMELCASE)
method
url
documentationUrl
parameters {
alias
allowNull
deprecated
description
enum
in
name
type
required
}
previews(required: true) {
name
}
headers {
name
value
required
}
responses {
code
description
schema
}
renamed {
note
}
Expand All @@ -53,7 +35,8 @@ main();

async function main() {
const { endpoints } = await graphql(QUERY, {
url: "https://github-openapi-graphql-server.vercel.app/api/graphql",
// url: "https://github-openapi-graphql-server.vercel.app/api/graphql",
url: "http://localhost:3000/api/graphql",
version,
ignoreChangesBefore: "2020-06-10",
});
Expand Down
Loading

0 comments on commit ad9c85d

Please sign in to comment.