Skip to content

Commit

Permalink
feat: v7 (#605)
Browse files Browse the repository at this point in the history

BREAKING CHANGE: package is now ESM
  • Loading branch information
wolfy1339 authored May 9, 2024
1 parent 231081b commit a65b4c3
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 176 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ jobs:
cache: npm
- run: npm ci
- run: npm run build
# https://github.com/octokit/action.js/pull/494
- name: "Fix pkg.files file pattern"
run: node scripts/fix-package-json.js
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coverage
node_modules/
pkg/
.vscode/
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ Node
Install with `npm install @octokit/action`

```js
const { Octokit } = require("@octokit/action");
// or: import { Octokit } from "@octokit/action";
import { Octokit } from "@octokit/action";
```

</td></tr>
</tbody>
</table>

> [!IMPORTANT]
> As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json` by setting `"moduleResolution": "node16", "module": "node16"`.
>
> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).<br>
> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus)
You can pass `secret.GITHUB_TOKEN` or any of your own secrets to a Node.js script. For example

```yml
Expand Down Expand Up @@ -59,7 +64,7 @@ Setting `GITHUB_TOKEN` on either [`with:`](https://help.github.com/en/actions/re

```js
// .github/actions/my-script.js
const { Octokit } = require("@octokit/action");
import { Octokit } from "@octokit/action";
const octokit = new Octokit();
Expand All @@ -69,7 +74,7 @@ const octokit = new Octokit();
### Create an issue using REST API

```js
const { Octokit } = require("@octokit/action");
import { Octokit } from "@octokit/action";

const octokit = new Octokit();
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
Expand All @@ -88,7 +93,7 @@ You can also use `octokit.issues.create({ owner, repo, title })`. See the [REST
### Create an issue using GraphQL

```js
const { Octokit } = require("@octokit/action");
import { Octokit } from "@octokit/action";

const octokit = new Octokit();
const eventPayload = require(process.env.GITHUB_EVENT_PATH);
Expand Down Expand Up @@ -130,7 +135,7 @@ type ChecksCreateResponse =

### Proxy Servers

If you use [self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners) and require a proxy server to access internet resources then you will need to ensure that you have correctly configured the runner for [proxy servers](https://docs.github.com/en/actions/hosting-your-own-runners/using-a-proxy-server-with-self-hosted-runners). `@octokit/action` will pick up the configured proxy server environment variables and configure `@octokit/core` with the correct `request.agent` using [proxy-agent](https://github.com/TooTallNate/node-proxy-agent/blob/master/index.js). If you need to supply a different `request.agent` then you should ensure that it handles proxy servers if needed.
If you use [self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners) and require a proxy server to access internet resources then you will need to ensure that you have correctly configured the runner for [proxy servers](https://docs.github.com/en/actions/hosting-your-own-runners/using-a-proxy-server-with-self-hosted-runners). `@octokit/action` will pick up the configured proxy server environment variables and configure `@octokit/core` with the correct `request.dispatcher` using [ProxyAgent](https://undici.nodejs.org/#/docs/api/ProxyAgent). If you need to supply a different `request.dispatcher` then you should ensure that it handles proxy servers if needed.

## How it works

Expand Down
161 changes: 78 additions & 83 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a65b4c3

Please sign in to comment.