docs-util: fix release scripts (#6353)
- Fix GitHub action to run on push and check if the commit message is "chore: Release". Only then are TSDocs generated and a PR is opened. - Add an option to pass to the `run:release` method of the docblock generator a release tag. This is helpful in cases when the GitHub action fails for any reason. - Add scripts that checks the message of a commit.
This commit is contained in:
38
docs-util/packages/scripts/check-release-commit.ts
Normal file
38
docs-util/packages/scripts/check-release-commit.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { Octokit } from "@octokit/core"
|
||||
import * as core from "@actions/core"
|
||||
|
||||
const commitSha = process.argv.length >= 3 ? process.argv[2] : null
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: process.env.GH_TOKEN,
|
||||
})
|
||||
|
||||
async function checkReleaseCommit() {
|
||||
if (!commitSha) {
|
||||
throw new Error("Commit SHA is required.")
|
||||
}
|
||||
|
||||
// retrieve commit by the SHA
|
||||
const { data: commit } = await octokit.request(
|
||||
"GET /repos/{owner}/{repo}/commits/{ref}",
|
||||
{
|
||||
owner: process.env.GIT_OWNER || "",
|
||||
repo: process.env.GIT_REPO || "",
|
||||
ref: commitSha,
|
||||
headers: {
|
||||
"X-GitHub-Api-Version": "2022-11-28",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
if (!commit) {
|
||||
throw new Error("Commit doesn't exist.")
|
||||
}
|
||||
|
||||
core.setOutput(
|
||||
"is_release_commit",
|
||||
commit.commit.message === "chore: Release"
|
||||
)
|
||||
}
|
||||
|
||||
void checkReleaseCommit()
|
||||
@@ -6,11 +6,13 @@
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"generate:announcement": "ts-node ./doc-change-release.ts",
|
||||
"generate:reference": "ts-node ./generate-reference.ts",
|
||||
"merge:references": "yarn generate:reference merge",
|
||||
"check:freshness": "ts-node ./freshness-check.ts",
|
||||
"generate:message": "ts-node ./get-generate-diff-message.ts"
|
||||
"generate:message": "ts-node ./get-generate-diff-message.ts",
|
||||
"check:release-commit": "node ./dist/check-release-commit.js"
|
||||
},
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"outDir": "./dist",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"rootDir": ".",
|
||||
},
|
||||
"include": ["*.ts"],
|
||||
"ts-node": {
|
||||
|
||||
Reference in New Issue
Block a user