Update to the latest version of @actions/github.

This commit is contained in:
Chris Gavin 2020-09-18 15:40:23 +01:00
parent 55458a1ab1
commit 9ed519fa12
No known key found for this signature in database
GPG key ID: 07F950B80C27E4DA
419 changed files with 56978 additions and 151535 deletions

View file

@ -3,8 +3,7 @@
> Send parameterized requests to GitHubs APIs with sensible defaults in browsers and Node
[![@latest](https://img.shields.io/npm/v/@octokit/request.svg)](https://www.npmjs.com/package/@octokit/request)
[![Build Status](https://github.com/octokit/request.js/workflows/Test/badge.svg)](https://github.com/octokit/request.js/actions?query=workflow%3ATest)
[![Greenkeeper](https://badges.greenkeeper.io/octokit/request.js.svg)](https://greenkeeper.io/)
[![Build Status](https://github.com/octokit/request.js/workflows/Test/badge.svg)](https://github.com/octokit/request.js/actions?query=workflow%3ATest+branch%3Amaster)
`@octokit/request` is a request library for browsers & node that makes it easier
to interact with [GitHubs REST API](https://developer.github.com/v3/) and
@ -41,12 +40,12 @@ the passed options and sends the request using [fetch](https://developer.mozilla
```js
request("POST /repos/:owner/:repo/issues/:number/labels", {
mediaType: {
previews: ["symmetra"]
previews: ["symmetra"],
},
owner: "octokit",
repo: "request.js",
number: 1,
labels: ["🐛 bug"]
labels: ["🐛 bug"],
});
```
@ -102,10 +101,10 @@ const { request } = require("@octokit/request");
// https://developer.github.com/v3/repos/#list-organization-repositories
const result = await request("GET /orgs/:org/repos", {
headers: {
authorization: "token 0000000000000000000000000000000000000001"
authorization: "token 0000000000000000000000000000000000000001",
},
org: "octokit",
type: "private"
type: "private",
});
console.log(`${result.data.length} repos found.`);
@ -118,7 +117,7 @@ For GraphQL request we recommend using [`@octokit/graphql`](https://github.com/o
```js
const result = await request("POST /graphql", {
headers: {
authorization: "token 0000000000000000000000000000000000000001"
authorization: "token 0000000000000000000000000000000000000001",
},
query: `query ($login: String!) {
organization(login: $login) {
@ -128,8 +127,8 @@ const result = await request("POST /graphql", {
}
}`,
variables: {
login: "octokit"
}
login: "octokit",
},
});
```
@ -142,10 +141,10 @@ const result = await request({
method: "GET",
url: "/orgs/:org/repos",
headers: {
authorization: "token 0000000000000000000000000000000000000001"
authorization: "token 0000000000000000000000000000000000000001",
},
org: "octokit",
type: "private"
type: "private",
});
```
@ -156,10 +155,10 @@ The simplest way to authenticate a request is to set the `Authorization` header
```js
const requestWithAuth = request.defaults({
headers: {
authorization: "token 0000000000000000000000000000000000000001"
}
authorization: "token 0000000000000000000000000000000000000001",
},
});
const result = await request("GET /user");
const result = await requestWithAuth("GET /user");
```
For more complex authentication strategies such as GitHub Apps or Basic, we recommend the according authentication library exported by [`@octokit/auth`](https://github.com/octokit/auth.js).
@ -169,22 +168,22 @@ const { createAppAuth } = require("@octokit/auth-app");
const auth = createAppAuth({
id: process.env.APP_ID,
privateKey: process.env.PRIVATE_KEY,
installationId: 123
installationId: 123,
});
const requestWithAuth = request.defaults({
request: {
hook: auth.hook
hook: auth.hook,
},
mediaType: {
previews: ["machine-man"]
}
previews: ["machine-man"],
},
});
const { data: app } = await requestWithAuth("GET /app");
const { data: app } = await requestWithAuth("POST /repos/:owner/:repo/issues", {
owner: "octocat",
repo: "hello-world",
title: "Hello from the engine room"
title: "Hello from the engine room",
});
```
@ -416,10 +415,10 @@ const myrequest = require("@octokit/request").defaults({
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
headers: {
"user-agent": "myApp/1.2.3",
authorization: `token 0000000000000000000000000000000000000001`
authorization: `token 0000000000000000000000000000000000000001`,
},
org: "my-project",
per_page: 100
per_page: 100,
});
myrequest(`GET /orgs/:org/repos`);
@ -431,14 +430,14 @@ You can call `.defaults()` again on the returned method, the defaults will casca
const myProjectRequest = request.defaults({
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
headers: {
"user-agent": "myApp/1.2.3"
"user-agent": "myApp/1.2.3",
},
org: "my-project"
org: "my-project",
});
const myProjectRequestWithAuth = myProjectRequest.defaults({
headers: {
authorization: `token 0000000000000000000000000000000000000001`
}
authorization: `token 0000000000000000000000000000000000000001`,
},
});
```
@ -453,7 +452,7 @@ See https://github.com/octokit/endpoint.js. Example
```js
const options = request.endpoint("GET /orgs/:org/repos", {
org: "my-project",
type: "private"
type: "private",
});
// {
@ -487,8 +486,8 @@ const response = await request("POST /markdown/raw", {
data: "Hello world github/linguist#1 **cool**, and #1!",
headers: {
accept: "text/html;charset=utf-8",
"content-type": "text/plain"
}
"content-type": "text/plain",
},
});
// Request is sent as
@ -527,9 +526,9 @@ request(
headers: {
"content-type": "text/plain",
"content-length": 14,
authorization: `token 0000000000000000000000000000000000000001`
authorization: `token 0000000000000000000000000000000000000001`,
},
data: "Hello, world!"
data: "Hello, world!",
}
);
```