Skip to content

Commit f23cd47

Browse files
committed
replace GitHub with octokit in the README, but keep a note of the GitHub still being available
1 parent 4024541 commit f23cd47

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

README.md

+18-18
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ uses the GitHub API and the workflow run context.
1010
To use this action, provide an input named `script` that contains the body of an asynchronous JavaScript function call.
1111
The following arguments will be provided:
1212

13-
- `github` A pre-authenticated
14-
[octokit/rest.js](https://octokit.github.io/rest.js) client with pagination plugins
13+
- `octokit` (and `github`) A pre-authenticated
14+
[octokit/rest.js](https://octokit.github.io/rest.js) client _instance_ with pagination plugins
1515
- `context` An object containing the [context of the workflow
1616
run](https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts)
1717
- `core` A reference to the [@actions/core](https://github.com/actions/toolkit/tree/main/packages/core) package
@@ -102,14 +102,14 @@ By default, requests made with the `github` instance will not be retried. You ca
102102
result-encoding: string
103103
retries: 3
104104
script: |
105-
github.rest.issues.get({
105+
octokit.rest.issues.get({
106106
issue_number: context.issue.number,
107107
owner: context.repo.owner,
108108
repo: context.repo.repo,
109109
})
110110
```
111111

112-
In this example, request failures from `github.rest.issues.get()` will be retried up to 3 times.
112+
In this example, request failures from `octokit.rest.issues.get()` will be retried up to 3 times.
113113

114114
You can also configure which status codes should be exempt from retries via the `retry-exempt-status-codes` option:
115115

@@ -121,7 +121,7 @@ You can also configure which status codes should be exempt from retries via the
121121
retries: 3
122122
retry-exempt-status-codes: 400,401
123123
script: |
124-
github.rest.issues.get({
124+
octokit.rest.issues.get({
125125
issue_number: context.issue.number,
126126
owner: context.repo.owner,
127127
repo: context.repo.repo,
@@ -162,7 +162,7 @@ jobs:
162162
- uses: actions/github-script@v7
163163
with:
164164
script: |
165-
github.rest.issues.createComment({
165+
octokit.rest.issues.createComment({
166166
issue_number: context.issue.number,
167167
owner: context.repo.owner,
168168
repo: context.repo.repo,
@@ -184,7 +184,7 @@ jobs:
184184
- uses: actions/github-script@v7
185185
with:
186186
script: |
187-
github.rest.issues.addLabels({
187+
octokit.rest.issues.addLabels({
188188
issue_number: context.issue.number,
189189
owner: context.repo.owner,
190190
repo: context.repo.repo,
@@ -209,12 +209,12 @@ jobs:
209209
// Get a list of all issues created by the PR opener
210210
// See: https://octokit.github.io/rest.js/#pagination
211211
const creator = context.payload.sender.login
212-
const opts = github.rest.issues.listForRepo.endpoint.merge({
212+
const opts = octokit.rest.issues.listForRepo.endpoint.merge({
213213
...context.issue,
214214
creator,
215215
state: 'all'
216216
})
217-
const issues = await github.paginate(opts)
217+
const issues = await octokit.paginate(opts)
218218
219219
for (const issue of issues) {
220220
if (issue.number === context.issue.number) {
@@ -226,7 +226,7 @@ jobs:
226226
}
227227
}
228228
229-
await github.rest.issues.createComment({
229+
await octokit.rest.issues.createComment({
230230
issue_number: context.issue.number,
231231
owner: context.repo.owner,
232232
repo: context.repo.repo,
@@ -252,7 +252,7 @@ jobs:
252252
with:
253253
script: |
254254
const diff_url = context.payload.pull_request.diff_url
255-
const result = await github.request(diff_url)
255+
const result = await octokit.request(diff_url)
256256
console.log(result)
257257
```
258258
@@ -289,7 +289,7 @@ jobs:
289289
name: context.repo.repo,
290290
label: 'wontfix'
291291
}
292-
const result = await github.graphql(query, variables)
292+
const result = await octokit.graphql(query, variables)
293293
console.log(result)
294294
```
295295

@@ -310,13 +310,13 @@ jobs:
310310
with:
311311
script: |
312312
const script = require('./path/to/script.js')
313-
console.log(script({github, context}))
313+
console.log(script({octokit, context}))
314314
```
315315
316316
And then export a function from your module:
317317
318318
```javascript
319-
module.exports = ({github, context}) => {
319+
module.exports = ({octokit, context}) => {
320320
return context.payload.client_payload.value
321321
}
322322
```
@@ -350,15 +350,15 @@ jobs:
350350
with:
351351
script: |
352352
const script = require('./path/to/script.js')
353-
await script({github, context, core})
353+
await script({octokit, context, core})
354354
```
355355
356356
And then export an async function from your module:
357357
358358
```javascript
359-
module.exports = async ({github, context, core}) => {
359+
module.exports = async ({octokit, context, core}) => {
360360
const {SHA} = process.env
361-
const commit = await github.rest.repos.getCommit({
361+
const commit = await octokit.rest.repos.getCommit({
362362
owner: context.repo.owner,
363363
repo: context.repo.repo,
364364
ref: `${SHA}`
@@ -487,7 +487,7 @@ jobs:
487487
with:
488488
github-token: ${{ secrets.MY_PAT }}
489489
script: |
490-
github.rest.issues.addLabels({
490+
octokit.rest.issues.addLabels({
491491
issue_number: context.issue.number,
492492
owner: context.repo.owner,
493493
repo: context.repo.repo,

0 commit comments

Comments
 (0)