From 68e1071aa7c4a108f3670d14649ec2afa1f705a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=8F=9C=20Cai?= Date: Tue, 17 Sep 2024 17:16:33 +0800 Subject: [PATCH 1/4] docs: Add permission instructions for `createComment` --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 09d8341f..ff345b81 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,10 @@ on: issues: types: [opened] +# see: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token +permissions: + pull-requests: 'write' + jobs: comment: runs-on: ubuntu-latest From cb6480baab02265a1f853604400fe0bc733a63a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=20Cai?= Date: Wed, 5 Feb 2025 11:03:19 +0800 Subject: [PATCH 2/4] chore: permissions issues --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ff345b81..10123fe5 100644 --- a/README.md +++ b/README.md @@ -35,21 +35,21 @@ documentation. ### V7 -Version 7 of this action updated the runtime to Node 20 - https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-javascript-actions +Version 7 of this action updated the runtime to Node 20 - All scripts are now run with Node 20 instead of Node 16 and are affected by any breaking changes between Node 16 and 20 -The `previews` input now only applies to GraphQL API calls as REST API previews are no longer necessary - https://github.blog/changelog/2021-10-14-rest-api-preview-promotions/. +The `previews` input now only applies to GraphQL API calls as REST API previews are no longer necessary - . ### V6 -Version 6 of this action updated the runtime to Node 16 - https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-javascript-actions +Version 6 of this action updated the runtime to Node 16 - All scripts are now run with Node 16 instead of Node 12 and are affected by any breaking changes between Node 12 and 16. ### 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 +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.*` - For example, `github.issues.createComment` in V4 becomes `github.rest.issues.createComment` in V5 @@ -157,7 +157,7 @@ on: # see: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token permissions: - pull-requests: 'write' + issues: 'write' jobs: comment: @@ -434,11 +434,13 @@ jobs: If you want type support for your scripts, you could use the command below to install the `github-script` type declaration. + ```sh -$ npm i -D @types/github-script@github:actions/github-script +npm i -D @types/github-script@github:actions/github-script ``` And then add the `jsDoc` declaration to your script like this: + ```js // @ts-check /** @param {import('@types/github-script').AsyncFunctionArguments} AsyncFunctionArguments */ From 8f1a91f5584ebd35dd0eddc9249a54a4442bf2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=20Cai?= Date: Wed, 5 Feb 2025 11:07:51 +0800 Subject: [PATCH 3/4] fix: lint --- README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 708ab1aa..9adc0269 100644 --- a/README.md +++ b/README.md @@ -35,21 +35,21 @@ documentation. ### V7 -Version 7 of this action updated the runtime to Node 20 - +Version 7 of this action updated the runtime to Node 20 - https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-javascript-actions All scripts are now run with Node 20 instead of Node 16 and are affected by any breaking changes between Node 16 and 20 -The `previews` input now only applies to GraphQL API calls as REST API previews are no longer necessary - . +The `previews` input now only applies to GraphQL API calls as REST API previews are no longer necessary - https://github.blog/changelog/2021-10-14-rest-api-preview-promotions/. ### V6 -Version 6 of this action updated the runtime to Node 16 - +Version 6 of this action updated the runtime to Node 16 - https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-javascript-actions All scripts are now run with Node 16 instead of Node 12 and are affected by any breaking changes between Node 12 and 16. ### 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.*` - +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 @@ -153,8 +153,7 @@ By default, github-script will use the token provided to your workflow. ```yaml on: issues: - types: [opened] - + # see: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token permissions: issues: 'write' @@ -432,14 +431,13 @@ jobs: ### Use scripts with jsDoc support -If you want type support for your scripts, you could use the command below to install the `@actions/github-script` type declaration. - +If you want type support for your scripts, you could use the command below to install the +`@actions/github-script` type declaration. ```sh $ npm i -D @actions/github-script@github:actions/github-script ``` And then add the `jsDoc` declaration to your script like this: - ```js // @ts-check /** @param {import('@actions/github-script').AsyncFunctionArguments} AsyncFunctionArguments */ From b8f7b475bb63fe60bc4834a4bb14870c0dc77274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=20Cai?= Date: Wed, 5 Feb 2025 11:19:53 +0800 Subject: [PATCH 4/4] chore: reset code --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9adc0269..6b78b23f 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ By default, github-script will use the token provided to your workflow. ```yaml on: issues: - + types: [opened] # see: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token permissions: issues: 'write'