|
1
|
import { Octokit } from "@octokit/core" |
|
2
|
import * as core from "@actions/core" |
|
3
|
|
|
4
|
const commitSha = process.argv.length >= 3 ? process.argv[2] : null |
|
5
|
|
|
6
|
const octokit = new Octokit({ |
|
7
|
auth: process.env.GH_TOKEN, |
|
8
|
}) |
|
9
|
|
|
10
|
async function checkReleaseCommit() { |
|
11
|
if (!commitSha) { |
|
12
|
throw new Error("Commit SHA is required.") |
|
13
|
} |
|
14
|
|
|
15
|
// retrieve commit by the SHA |
|
16
|
const { data: commit } = await octokit.request( |
|
17
|
"GET /repos/{owner}/{repo}/commits/{ref}", |
|
18
|
{ |
|
19
|
owner: process.env.GIT_OWNER || "", |
|
20
|
repo: process.env.GIT_REPO || "", |
|
21
|
ref: commitSha, |
|
22
|
headers: { |
|
23
|
"X-GitHub-Api-Version": "2022-11-28", |
|
24
|
}, |
|
25
|
} |
|
26
|
) |
|
27
|
|
|
28
|
if (!commit) { |
|
29
|
throw new Error("Commit doesn't exist.") |
|
30
|
} |
|
31
|
|
|
32
|
core.setOutput( |
|
33
|
"is_release_commit", |
|
34
|
commit.commit.message === "chore: Release" |
|
35
|
) |
|
36
|
} |
|
37
|
|
|
38
|
void checkReleaseCommit() |