Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to the latest version of Octokit #193

Merged
merged 3 commits into from Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/pull-request-test.yml
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
script: |
// Get the existing comments.
const {data: comments} = await github.issues.listComments({
const {data: comments} = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
Expand All @@ -28,14 +28,14 @@ jobs:
console.log('Not attempting to write comment on PR from fork');
} else {
if (botComment) {
await github.issues.updateComment({
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
})
} else {
await github.issues.createComment({
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
Expand Down
30 changes: 10 additions & 20 deletions .licenses/npm/@actions/github.dep.yml

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

2 changes: 1 addition & 1 deletion .licenses/npm/@actions/glob.dep.yml

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

2 changes: 1 addition & 1 deletion .licenses/npm/@actions/http-client.dep.yml

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

2 changes: 1 addition & 1 deletion .licenses/npm/@octokit/openapi-types.dep.yml

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

4 changes: 2 additions & 2 deletions .licenses/npm/@octokit/plugin-rest-endpoint-methods.dep.yml

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

20 changes: 0 additions & 20 deletions .licenses/npm/@octokit/types-5.5.0.dep.yml

This file was deleted.

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

32 changes: 0 additions & 32 deletions .licenses/npm/@types/node.dep.yml

This file was deleted.

45 changes: 25 additions & 20 deletions README.md
Expand Up @@ -32,8 +32,13 @@ defined, so you don't have to (see examples below).
See [octokit/rest.js](https://octokit.github.io/rest.js/) for the API client
documentation.

**Note** This action is still a bit of an experiment—the API may change in
future versions. 🙂
## Breaking changes in V5

Version 5 of this action includes the version 5 of `@actions/github` and `@octokit/plugin-rest-endpoint-methods`. As part of this update, the Octokit context available via `github` no longer has REST methods directly. These methods are available via `github.rest.*` - https://github.com/octokit/plugin-rest-endpoint-methods.js/releases/tag/v5.0.0

For example, `github.issues.createComment` in V4 becomes `github.rest.issues.createComment` in V5

`github.request`, `github.paginate`, and `github.graphql` are unchanged.

## Development

Expand All @@ -45,7 +50,7 @@ The return value of the script will be in the step's outputs under the
"result" key.

```yaml
- uses: actions/github-script@v4
- uses: actions/github-script@v5
id: set-result
with:
script: return "Hello!"
Expand All @@ -64,7 +69,7 @@ output of a github-script step. For some workflows, string encoding is preferred
`result-encoding` input:

```yaml
- uses: actions/github-script@v4
- uses: actions/github-script@v5
id: my-script
with:
result-encoding: string
Expand All @@ -82,7 +87,7 @@ By default, github-script will use the token provided to your workflow.

```yaml
- name: View context attributes
uses: actions/github-script@v4
uses: actions/github-script@v5
with:
script: console.log(context)
```
Expand All @@ -98,10 +103,10 @@ jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v4
- uses: actions/github-script@v5
with:
script: |
github.issues.createComment({
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -120,10 +125,10 @@ jobs:
apply-label:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v4
- uses: actions/github-script@v5
with:
script: |
github.issues.addLabels({
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -140,13 +145,13 @@ jobs:
welcome:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v4
- uses: actions/github-script@v5
with:
script: |
// Get a list of all issues created by the PR opener
// See: https://octokit.github.io/rest.js/#pagination
const creator = context.payload.sender.login
const opts = github.issues.listForRepo.endpoint.merge({
const opts = github.rest.issues.listForRepo.endpoint.merge({
...context.issue,
creator,
state: 'all'
Expand All @@ -163,7 +168,7 @@ jobs:
}
}

await github.issues.createComment({
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -183,7 +188,7 @@ jobs:
diff:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v4
- uses: actions/github-script@v5
with:
script: |
const diff_url = context.payload.pull_request.diff_url
Expand All @@ -207,7 +212,7 @@ jobs:
list-issues:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v4
- uses: actions/github-script@v5
with:
script: |
const query = `query($owner:String!, $name:String!, $label:String!) {
Expand Down Expand Up @@ -241,7 +246,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/github-script@v4
- uses: actions/github-script@v5
with:
script: |
const script = require('./path/to/script.js')
Expand Down Expand Up @@ -279,7 +284,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/github-script@v4
- uses: actions/github-script@v5
env:
SHA: '${{env.parentSHA}}'
with:
Expand Down Expand Up @@ -323,7 +328,7 @@ jobs:
- run: npm ci
# or one-off:
- run: npm install execa
- uses: actions/github-script@v4
- uses: actions/github-script@v5
with:
script: |
const execa = require('execa')
Expand All @@ -344,7 +349,7 @@ jobs:
echo-input:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v4
- uses: actions/github-script@v5
env:
FIRST_NAME: Mona
LAST_NAME: Octocat
Expand Down Expand Up @@ -372,11 +377,11 @@ jobs:
apply-label:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v4
- uses: actions/github-script@v5
with:
github-token: ${{ secrets.MY_PAT }}
script: |
github.issues.addLabels({
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down