diff --git a/action.yml b/action.yml index a242902..38b29cb 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ name: "GitHub cherry pick action" -description: "GitHub action for cherry pick commits from Pull Requests into Release branchs" +description: "GitHub action for cherry pick commits from Pull Requests into Release branches" inputs: token: description: "GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT)" @@ -54,7 +54,7 @@ inputs: description: "Forcefully push the branch to remote branch" required: false runs: - using: node16 + using: node20 main: dist/index.js branding: icon: 'git-pull-request' diff --git a/package-lock.json b/package-lock.json index 269f452..1c4fcf8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@actions/exec": "^1.1.1", "@actions/github": "^6.0.0", "@actions/io": "^1.1.3", - "@octokit/webhooks-definitions": "^3.67.3" + "@octokit/webhooks-types": "^7.4.0" }, "devDependencies": { "@types/jest": "^29.5.12", @@ -1894,11 +1894,10 @@ "@octokit/openapi-types": "^20.0.0" } }, - "node_modules/@octokit/webhooks-definitions": { - "version": "3.67.3", - "resolved": "https://registry.npmjs.org/@octokit/webhooks-definitions/-/webhooks-definitions-3.67.3.tgz", - "integrity": "sha512-do4Z1r2OVhuI0ihJhQ8Hg+yPWnBYEBNuFNCrvtPKoYT1w81jD7pBXgGe86lYuuNirkDHb0Nxt+zt4O5GiFJfgA==", - "deprecated": "Use @octokit/webhooks-types, @octokit/webhooks-schemas, or @octokit/webhooks-examples instead. See https://github.com/octokit/webhooks/issues/447" + "node_modules/@octokit/webhooks-types": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@octokit/webhooks-types/-/webhooks-types-7.4.0.tgz", + "integrity": "sha512-FE2V+QZ2UYlh+9wWd5BPLNXG+J/XUD/PPq0ovS+nCcGX4+3qVbi3jYOmCTW48hg9SBBLtInx9+o7fFt4H5iP0Q==" }, "node_modules/@pkgr/core": { "version": "0.1.1", @@ -9791,10 +9790,10 @@ "@octokit/openapi-types": "^20.0.0" } }, - "@octokit/webhooks-definitions": { - "version": "3.67.3", - "resolved": "https://registry.npmjs.org/@octokit/webhooks-definitions/-/webhooks-definitions-3.67.3.tgz", - "integrity": "sha512-do4Z1r2OVhuI0ihJhQ8Hg+yPWnBYEBNuFNCrvtPKoYT1w81jD7pBXgGe86lYuuNirkDHb0Nxt+zt4O5GiFJfgA==" + "@octokit/webhooks-types": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@octokit/webhooks-types/-/webhooks-types-7.4.0.tgz", + "integrity": "sha512-FE2V+QZ2UYlh+9wWd5BPLNXG+J/XUD/PPq0ovS+nCcGX4+3qVbi3jYOmCTW48hg9SBBLtInx9+o7fFt4H5iP0Q==" }, "@pkgr/core": { "version": "0.1.1", diff --git a/package.json b/package.json index e71b5fb..670d7f3 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@actions/exec": "^1.1.1", "@actions/github": "^6.0.0", "@actions/io": "^1.1.3", - "@octokit/webhooks-definitions": "^3.67.3" + "@octokit/webhooks-types": "^7.4.0" }, "devDependencies": { "@types/jest": "^29.5.12", diff --git a/src/github-helper.ts b/src/github-helper.ts index ad00fd6..4bca9b3 100644 --- a/src/github-helper.ts +++ b/src/github-helper.ts @@ -1,6 +1,6 @@ import * as github from '@actions/github' import * as core from '@actions/core' -import {PullRequest} from '@octokit/webhooks-definitions/schema' +import {PullRequest} from '@octokit/webhooks-types' const ERROR_PR_REVIEW_FROM_AUTHOR = 'Review cannot be requested from pull request author' @@ -50,7 +50,7 @@ export async function createPullRequest( core.info(`Input body is '${inputs.body}'`) let body = inputs.body if (body === undefined || body === '') { - body = pull_request.body + body = pull_request.body || undefined } else { // if the body comes from inputs, we replace {old_pull_request_id} // to make it easy to reference the previous pull request in the new diff --git a/src/index.ts b/src/index.ts index 24d7346..9523752 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ import * as exec from '@actions/exec' import * as utils from './utils' import * as github from '@actions/github' import {Inputs, createPullRequest} from './github-helper' -import { PullRequest } from '@octokit/webhooks-definitions/schema' +import {PullRequest} from '@octokit/webhooks-types' const CHERRYPICK_EMPTY = 'The previous cherry-pick is now empty, possibly due to conflict resolution.' @@ -31,7 +31,8 @@ export async function run(): Promise { // the value of merge_commit_sha changes depending on the status of the pull request // see https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request - const githubSha = (github.context.payload.pull_request as PullRequest).merge_commit_sha + const githubSha = (github.context.payload.pull_request as PullRequest) + .merge_commit_sha const prBranch = inputs.cherryPickBranch ? inputs.cherryPickBranch : `cherry-pick-${inputs.branch}-${githubSha}` diff --git a/test/index.test.ts b/test/index.test.ts index cce0744..5d124fb 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -2,7 +2,7 @@ import * as core from '@actions/core' import * as exec from '@actions/exec' import {run} from '../src/index' import {createPullRequest} from '../src/github-helper' -import { PullRequest } from '@octokit/webhooks-definitions/schema' +import {PullRequest} from '@octokit/webhooks-types' const defaultMockedGetInputData: any = { token: 'whatever',