mirror of
https://github.com/graalvm/setup-graalvm.git
synced 2025-07-26 06:43:13 +08:00
Use @actions/github
instead of @octokit/core
.
This commit is contained in:
parent
356b5a68f4
commit
372a8049d7
45
dist/cleanup/index.js
generated
vendored
45
dist/cleanup/index.js
generated
vendored
@ -79190,24 +79190,15 @@ exports.setNativeImageOption = setNativeImageOption;
|
|||||||
const c = __importStar(__nccwpck_require__(7242));
|
const c = __importStar(__nccwpck_require__(7242));
|
||||||
const core = __importStar(__nccwpck_require__(7484));
|
const core = __importStar(__nccwpck_require__(7484));
|
||||||
const github = __importStar(__nccwpck_require__(3228));
|
const github = __importStar(__nccwpck_require__(3228));
|
||||||
const httpClient = __importStar(__nccwpck_require__(4844));
|
|
||||||
const semver = __importStar(__nccwpck_require__(2088));
|
const semver = __importStar(__nccwpck_require__(2088));
|
||||||
const tc = __importStar(__nccwpck_require__(3472));
|
const tc = __importStar(__nccwpck_require__(3472));
|
||||||
const fs = __importStar(__nccwpck_require__(9896));
|
const fs = __importStar(__nccwpck_require__(9896));
|
||||||
const exec_1 = __nccwpck_require__(5236);
|
const exec_1 = __nccwpck_require__(5236);
|
||||||
const fs_1 = __nccwpck_require__(9896);
|
const fs_1 = __nccwpck_require__(9896);
|
||||||
const core_1 = __nccwpck_require__(1897);
|
|
||||||
const crypto_1 = __nccwpck_require__(6982);
|
const crypto_1 = __nccwpck_require__(6982);
|
||||||
const path_1 = __nccwpck_require__(6928);
|
const path_1 = __nccwpck_require__(6928);
|
||||||
const os_1 = __nccwpck_require__(857);
|
const os_1 = __nccwpck_require__(857);
|
||||||
// Set up Octokit for github.com only and in the same way as @actions/github (see https://git.io/Jy9YP)
|
const utils_1 = __nccwpck_require__(8006);
|
||||||
const baseUrl = 'https://api.github.com';
|
|
||||||
const GitHubDotCom = core_1.Octokit.defaults({
|
|
||||||
baseUrl,
|
|
||||||
request: {
|
|
||||||
agent: new httpClient.HttpClient().getAgent(baseUrl)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
async function exec(commandLine, args, options) {
|
async function exec(commandLine, args, options) {
|
||||||
const exitCode = await (0, exec_1.exec)(commandLine, args, options);
|
const exitCode = await (0, exec_1.exec)(commandLine, args, options);
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
@ -79215,18 +79206,14 @@ async function exec(commandLine, args, options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function getLatestRelease(repo) {
|
async function getLatestRelease(repo) {
|
||||||
const githubToken = getGitHubToken();
|
const octokit = getOctokit();
|
||||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
|
||||||
const octokit = new GitHubDotCom(options);
|
|
||||||
return (await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
return (await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
||||||
owner: c.GRAALVM_GH_USER,
|
owner: c.GRAALVM_GH_USER,
|
||||||
repo
|
repo
|
||||||
})).data;
|
})).data;
|
||||||
}
|
}
|
||||||
async function getContents(repo, path) {
|
async function getContents(repo, path) {
|
||||||
const githubToken = getGitHubToken();
|
const octokit = getOctokit();
|
||||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
|
||||||
const octokit = new GitHubDotCom(options);
|
|
||||||
return (await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
|
return (await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
|
||||||
owner: c.GRAALVM_GH_USER,
|
owner: c.GRAALVM_GH_USER,
|
||||||
repo,
|
repo,
|
||||||
@ -79234,9 +79221,7 @@ async function getContents(repo, path) {
|
|||||||
})).data;
|
})).data;
|
||||||
}
|
}
|
||||||
async function getTaggedRelease(owner, repo, tag) {
|
async function getTaggedRelease(owner, repo, tag) {
|
||||||
const githubToken = getGitHubToken();
|
const octokit = getOctokit();
|
||||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
|
||||||
const octokit = new GitHubDotCom(options);
|
|
||||||
return (await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
|
return (await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@ -79244,9 +79229,7 @@ async function getTaggedRelease(owner, repo, tag) {
|
|||||||
})).data;
|
})).data;
|
||||||
}
|
}
|
||||||
async function getMatchingTags(owner, repo, tagPrefix) {
|
async function getMatchingTags(owner, repo, tagPrefix) {
|
||||||
const githubToken = getGitHubToken();
|
const octokit = getOctokit();
|
||||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
|
||||||
const octokit = new GitHubDotCom(options);
|
|
||||||
return (await octokit.request('GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}', {
|
return (await octokit.request('GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}', {
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@ -79314,15 +79297,23 @@ function toSemVer(version) {
|
|||||||
function isPREvent() {
|
function isPREvent() {
|
||||||
return process.env[c.ENV_GITHUB_EVENT_NAME] === c.EVENT_NAME_PULL_REQUEST;
|
return process.env[c.ENV_GITHUB_EVENT_NAME] === c.EVENT_NAME_PULL_REQUEST;
|
||||||
}
|
}
|
||||||
function getGitHubToken() {
|
function getOctokit() {
|
||||||
return core.getInput(c.INPUT_GITHUB_TOKEN);
|
/* Set up GitHub instance manually because @actions/github does not allow unauthenticated access */
|
||||||
|
const GitHubWithPlugins = utils_1.GitHub.plugin();
|
||||||
|
const token = core.getInput(c.INPUT_GITHUB_TOKEN);
|
||||||
|
if (token) {
|
||||||
|
return new GitHubWithPlugins({ auth: `token ${token}` });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return new GitHubWithPlugins(); /* unauthenticated */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async function findExistingPRCommentId(bodyStartsWith) {
|
async function findExistingPRCommentId(bodyStartsWith) {
|
||||||
if (!isPREvent()) {
|
if (!isPREvent()) {
|
||||||
throw new Error('Not a PR event.');
|
throw new Error('Not a PR event.');
|
||||||
}
|
}
|
||||||
const context = github.context;
|
const context = github.context;
|
||||||
const octokit = github.getOctokit(getGitHubToken());
|
const octokit = getOctokit();
|
||||||
try {
|
try {
|
||||||
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
|
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
|
||||||
...context.repo,
|
...context.repo,
|
||||||
@ -79342,7 +79333,7 @@ async function updatePRComment(content, commentId) {
|
|||||||
throw new Error('Not a PR event.');
|
throw new Error('Not a PR event.');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await github.getOctokit(getGitHubToken()).rest.issues.updateComment({
|
await getOctokit().rest.issues.updateComment({
|
||||||
...github.context.repo,
|
...github.context.repo,
|
||||||
comment_id: commentId,
|
comment_id: commentId,
|
||||||
body: content
|
body: content
|
||||||
@ -79358,7 +79349,7 @@ async function createPRComment(content) {
|
|||||||
}
|
}
|
||||||
const context = github.context;
|
const context = github.context;
|
||||||
try {
|
try {
|
||||||
await github.getOctokit(getGitHubToken()).rest.issues.createComment({
|
await getOctokit().rest.issues.createComment({
|
||||||
...context.repo,
|
...context.repo,
|
||||||
issue_number: context.payload.pull_request?.number,
|
issue_number: context.payload.pull_request?.number,
|
||||||
body: content
|
body: content
|
||||||
|
45
dist/main/index.js
generated
vendored
45
dist/main/index.js
generated
vendored
@ -80484,24 +80484,15 @@ exports.setNativeImageOption = setNativeImageOption;
|
|||||||
const c = __importStar(__nccwpck_require__(7242));
|
const c = __importStar(__nccwpck_require__(7242));
|
||||||
const core = __importStar(__nccwpck_require__(7484));
|
const core = __importStar(__nccwpck_require__(7484));
|
||||||
const github = __importStar(__nccwpck_require__(3228));
|
const github = __importStar(__nccwpck_require__(3228));
|
||||||
const httpClient = __importStar(__nccwpck_require__(4844));
|
|
||||||
const semver = __importStar(__nccwpck_require__(2088));
|
const semver = __importStar(__nccwpck_require__(2088));
|
||||||
const tc = __importStar(__nccwpck_require__(3472));
|
const tc = __importStar(__nccwpck_require__(3472));
|
||||||
const fs = __importStar(__nccwpck_require__(9896));
|
const fs = __importStar(__nccwpck_require__(9896));
|
||||||
const exec_1 = __nccwpck_require__(5236);
|
const exec_1 = __nccwpck_require__(5236);
|
||||||
const fs_1 = __nccwpck_require__(9896);
|
const fs_1 = __nccwpck_require__(9896);
|
||||||
const core_1 = __nccwpck_require__(1897);
|
|
||||||
const crypto_1 = __nccwpck_require__(6982);
|
const crypto_1 = __nccwpck_require__(6982);
|
||||||
const path_1 = __nccwpck_require__(6928);
|
const path_1 = __nccwpck_require__(6928);
|
||||||
const os_1 = __nccwpck_require__(857);
|
const os_1 = __nccwpck_require__(857);
|
||||||
// Set up Octokit for github.com only and in the same way as @actions/github (see https://git.io/Jy9YP)
|
const utils_1 = __nccwpck_require__(8006);
|
||||||
const baseUrl = 'https://api.github.com';
|
|
||||||
const GitHubDotCom = core_1.Octokit.defaults({
|
|
||||||
baseUrl,
|
|
||||||
request: {
|
|
||||||
agent: new httpClient.HttpClient().getAgent(baseUrl)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
async function exec(commandLine, args, options) {
|
async function exec(commandLine, args, options) {
|
||||||
const exitCode = await (0, exec_1.exec)(commandLine, args, options);
|
const exitCode = await (0, exec_1.exec)(commandLine, args, options);
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
@ -80509,18 +80500,14 @@ async function exec(commandLine, args, options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function getLatestRelease(repo) {
|
async function getLatestRelease(repo) {
|
||||||
const githubToken = getGitHubToken();
|
const octokit = getOctokit();
|
||||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
|
||||||
const octokit = new GitHubDotCom(options);
|
|
||||||
return (await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
return (await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
||||||
owner: c.GRAALVM_GH_USER,
|
owner: c.GRAALVM_GH_USER,
|
||||||
repo
|
repo
|
||||||
})).data;
|
})).data;
|
||||||
}
|
}
|
||||||
async function getContents(repo, path) {
|
async function getContents(repo, path) {
|
||||||
const githubToken = getGitHubToken();
|
const octokit = getOctokit();
|
||||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
|
||||||
const octokit = new GitHubDotCom(options);
|
|
||||||
return (await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
|
return (await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
|
||||||
owner: c.GRAALVM_GH_USER,
|
owner: c.GRAALVM_GH_USER,
|
||||||
repo,
|
repo,
|
||||||
@ -80528,9 +80515,7 @@ async function getContents(repo, path) {
|
|||||||
})).data;
|
})).data;
|
||||||
}
|
}
|
||||||
async function getTaggedRelease(owner, repo, tag) {
|
async function getTaggedRelease(owner, repo, tag) {
|
||||||
const githubToken = getGitHubToken();
|
const octokit = getOctokit();
|
||||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
|
||||||
const octokit = new GitHubDotCom(options);
|
|
||||||
return (await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
|
return (await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@ -80538,9 +80523,7 @@ async function getTaggedRelease(owner, repo, tag) {
|
|||||||
})).data;
|
})).data;
|
||||||
}
|
}
|
||||||
async function getMatchingTags(owner, repo, tagPrefix) {
|
async function getMatchingTags(owner, repo, tagPrefix) {
|
||||||
const githubToken = getGitHubToken();
|
const octokit = getOctokit();
|
||||||
const options = githubToken.length > 0 ? { auth: githubToken } : {};
|
|
||||||
const octokit = new GitHubDotCom(options);
|
|
||||||
return (await octokit.request('GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}', {
|
return (await octokit.request('GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}', {
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@ -80608,15 +80591,23 @@ function toSemVer(version) {
|
|||||||
function isPREvent() {
|
function isPREvent() {
|
||||||
return process.env[c.ENV_GITHUB_EVENT_NAME] === c.EVENT_NAME_PULL_REQUEST;
|
return process.env[c.ENV_GITHUB_EVENT_NAME] === c.EVENT_NAME_PULL_REQUEST;
|
||||||
}
|
}
|
||||||
function getGitHubToken() {
|
function getOctokit() {
|
||||||
return core.getInput(c.INPUT_GITHUB_TOKEN);
|
/* Set up GitHub instance manually because @actions/github does not allow unauthenticated access */
|
||||||
|
const GitHubWithPlugins = utils_1.GitHub.plugin();
|
||||||
|
const token = core.getInput(c.INPUT_GITHUB_TOKEN);
|
||||||
|
if (token) {
|
||||||
|
return new GitHubWithPlugins({ auth: `token ${token}` });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return new GitHubWithPlugins(); /* unauthenticated */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async function findExistingPRCommentId(bodyStartsWith) {
|
async function findExistingPRCommentId(bodyStartsWith) {
|
||||||
if (!isPREvent()) {
|
if (!isPREvent()) {
|
||||||
throw new Error('Not a PR event.');
|
throw new Error('Not a PR event.');
|
||||||
}
|
}
|
||||||
const context = github.context;
|
const context = github.context;
|
||||||
const octokit = github.getOctokit(getGitHubToken());
|
const octokit = getOctokit();
|
||||||
try {
|
try {
|
||||||
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
|
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
|
||||||
...context.repo,
|
...context.repo,
|
||||||
@ -80636,7 +80627,7 @@ async function updatePRComment(content, commentId) {
|
|||||||
throw new Error('Not a PR event.');
|
throw new Error('Not a PR event.');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await github.getOctokit(getGitHubToken()).rest.issues.updateComment({
|
await getOctokit().rest.issues.updateComment({
|
||||||
...github.context.repo,
|
...github.context.repo,
|
||||||
comment_id: commentId,
|
comment_id: commentId,
|
||||||
body: content
|
body: content
|
||||||
@ -80652,7 +80643,7 @@ async function createPRComment(content) {
|
|||||||
}
|
}
|
||||||
const context = github.context;
|
const context = github.context;
|
||||||
try {
|
try {
|
||||||
await github.getOctokit(getGitHubToken()).rest.issues.createComment({
|
await getOctokit().rest.issues.createComment({
|
||||||
...context.repo,
|
...context.repo,
|
||||||
issue_number: context.payload.pull_request?.number,
|
issue_number: context.payload.pull_request?.number,
|
||||||
body: content
|
body: content
|
||||||
|
1
package-lock.json
generated
1
package-lock.json
generated
@ -18,7 +18,6 @@
|
|||||||
"@actions/io": "^1.1.3",
|
"@actions/io": "^1.1.3",
|
||||||
"@actions/tool-cache": "^2.0.2",
|
"@actions/tool-cache": "^2.0.2",
|
||||||
"@github/dependency-submission-toolkit": "^2.0.5",
|
"@github/dependency-submission-toolkit": "^2.0.5",
|
||||||
"@octokit/core": "^5.2.0",
|
|
||||||
"@octokit/types": "^14.1.0",
|
"@octokit/types": "^14.1.0",
|
||||||
"semver": "^7.7.2",
|
"semver": "^7.7.2",
|
||||||
"uuid": "^11.1.0"
|
"uuid": "^11.1.0"
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
"@actions/http-client": "^2.2.3",
|
"@actions/http-client": "^2.2.3",
|
||||||
"@actions/io": "^1.1.3",
|
"@actions/io": "^1.1.3",
|
||||||
"@actions/tool-cache": "^2.0.2",
|
"@actions/tool-cache": "^2.0.2",
|
||||||
"@octokit/core": "^5.2.0",
|
|
||||||
"@octokit/types": "^14.1.0",
|
"@octokit/types": "^14.1.0",
|
||||||
"@github/dependency-submission-toolkit": "^2.0.5",
|
"@github/dependency-submission-toolkit": "^2.0.5",
|
||||||
"semver": "^7.7.2",
|
"semver": "^7.7.2",
|
||||||
|
45
src/utils.ts
45
src/utils.ts
@ -1,25 +1,15 @@
|
|||||||
import * as c from './constants'
|
import * as c from './constants'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as github from '@actions/github'
|
import * as github from '@actions/github'
|
||||||
import * as httpClient from '@actions/http-client'
|
|
||||||
import * as semver from 'semver'
|
import * as semver from 'semver'
|
||||||
import * as tc from '@actions/tool-cache'
|
import * as tc from '@actions/tool-cache'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import { ExecOptions, exec as e } from '@actions/exec'
|
import { ExecOptions, exec as e } from '@actions/exec'
|
||||||
import { readFileSync, readdirSync } from 'fs'
|
import { readFileSync, readdirSync } from 'fs'
|
||||||
import { Octokit } from '@octokit/core'
|
|
||||||
import { createHash } from 'crypto'
|
import { createHash } from 'crypto'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { tmpdir } from 'os'
|
import { tmpdir } from 'os'
|
||||||
|
import { GitHub } from '@actions/github/lib/utils'
|
||||||
// Set up Octokit for github.com only and in the same way as @actions/github (see https://git.io/Jy9YP)
|
|
||||||
const baseUrl = 'https://api.github.com'
|
|
||||||
const GitHubDotCom = Octokit.defaults({
|
|
||||||
baseUrl,
|
|
||||||
request: {
|
|
||||||
agent: new httpClient.HttpClient().getAgent(baseUrl)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export async function exec(commandLine: string, args?: string[], options?: ExecOptions | undefined): Promise<void> {
|
export async function exec(commandLine: string, args?: string[], options?: ExecOptions | undefined): Promise<void> {
|
||||||
const exitCode = await e(commandLine, args, options)
|
const exitCode = await e(commandLine, args, options)
|
||||||
@ -29,9 +19,7 @@ export async function exec(commandLine: string, args?: string[], options?: ExecO
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getLatestRelease(repo: string): Promise<c.LatestReleaseResponse['data']> {
|
export async function getLatestRelease(repo: string): Promise<c.LatestReleaseResponse['data']> {
|
||||||
const githubToken = getGitHubToken()
|
const octokit = getOctokit()
|
||||||
const options = githubToken.length > 0 ? { auth: githubToken } : {}
|
|
||||||
const octokit = new GitHubDotCom(options)
|
|
||||||
return (
|
return (
|
||||||
await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
await octokit.request('GET /repos/{owner}/{repo}/releases/latest', {
|
||||||
owner: c.GRAALVM_GH_USER,
|
owner: c.GRAALVM_GH_USER,
|
||||||
@ -41,9 +29,7 @@ export async function getLatestRelease(repo: string): Promise<c.LatestReleaseRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getContents(repo: string, path: string): Promise<c.ContentsResponse['data']> {
|
export async function getContents(repo: string, path: string): Promise<c.ContentsResponse['data']> {
|
||||||
const githubToken = getGitHubToken()
|
const octokit = getOctokit()
|
||||||
const options = githubToken.length > 0 ? { auth: githubToken } : {}
|
|
||||||
const octokit = new GitHubDotCom(options)
|
|
||||||
return (
|
return (
|
||||||
await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
|
await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
|
||||||
owner: c.GRAALVM_GH_USER,
|
owner: c.GRAALVM_GH_USER,
|
||||||
@ -58,9 +44,7 @@ export async function getTaggedRelease(
|
|||||||
repo: string,
|
repo: string,
|
||||||
tag: string
|
tag: string
|
||||||
): Promise<c.LatestReleaseResponse['data']> {
|
): Promise<c.LatestReleaseResponse['data']> {
|
||||||
const githubToken = getGitHubToken()
|
const octokit = getOctokit()
|
||||||
const options = githubToken.length > 0 ? { auth: githubToken } : {}
|
|
||||||
const octokit = new GitHubDotCom(options)
|
|
||||||
return (
|
return (
|
||||||
await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
|
await octokit.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
|
||||||
owner,
|
owner,
|
||||||
@ -75,9 +59,7 @@ export async function getMatchingTags(
|
|||||||
repo: string,
|
repo: string,
|
||||||
tagPrefix: string
|
tagPrefix: string
|
||||||
): Promise<c.MatchingRefsResponse['data']> {
|
): Promise<c.MatchingRefsResponse['data']> {
|
||||||
const githubToken = getGitHubToken()
|
const octokit = getOctokit()
|
||||||
const options = githubToken.length > 0 ? { auth: githubToken } : {}
|
|
||||||
const octokit = new GitHubDotCom(options)
|
|
||||||
return (
|
return (
|
||||||
await octokit.request('GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}', {
|
await octokit.request('GET /repos/{owner}/{repo}/git/matching-refs/tags/{tagPrefix}', {
|
||||||
owner,
|
owner,
|
||||||
@ -156,8 +138,15 @@ export function isPREvent(): boolean {
|
|||||||
return process.env[c.ENV_GITHUB_EVENT_NAME] === c.EVENT_NAME_PULL_REQUEST
|
return process.env[c.ENV_GITHUB_EVENT_NAME] === c.EVENT_NAME_PULL_REQUEST
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGitHubToken(): string {
|
function getOctokit(): InstanceType<typeof GitHub> {
|
||||||
return core.getInput(c.INPUT_GITHUB_TOKEN)
|
/* Set up GitHub instance manually because @actions/github does not allow unauthenticated access */
|
||||||
|
const GitHubWithPlugins = GitHub.plugin()
|
||||||
|
const token = core.getInput(c.INPUT_GITHUB_TOKEN)
|
||||||
|
if (token) {
|
||||||
|
return new GitHubWithPlugins({ auth: `token ${token}` })
|
||||||
|
} else {
|
||||||
|
return new GitHubWithPlugins() /* unauthenticated */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function findExistingPRCommentId(bodyStartsWith: string): Promise<number | undefined> {
|
export async function findExistingPRCommentId(bodyStartsWith: string): Promise<number | undefined> {
|
||||||
@ -166,7 +155,7 @@ export async function findExistingPRCommentId(bodyStartsWith: string): Promise<n
|
|||||||
}
|
}
|
||||||
|
|
||||||
const context = github.context
|
const context = github.context
|
||||||
const octokit = github.getOctokit(getGitHubToken())
|
const octokit = getOctokit()
|
||||||
try {
|
try {
|
||||||
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
|
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
|
||||||
...context.repo,
|
...context.repo,
|
||||||
@ -189,7 +178,7 @@ export async function updatePRComment(content: string, commentId: number): Promi
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await github.getOctokit(getGitHubToken()).rest.issues.updateComment({
|
await getOctokit().rest.issues.updateComment({
|
||||||
...github.context.repo,
|
...github.context.repo,
|
||||||
comment_id: commentId,
|
comment_id: commentId,
|
||||||
body: content
|
body: content
|
||||||
@ -207,7 +196,7 @@ export async function createPRComment(content: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
const context = github.context
|
const context = github.context
|
||||||
try {
|
try {
|
||||||
await github.getOctokit(getGitHubToken()).rest.issues.createComment({
|
await getOctokit().rest.issues.createComment({
|
||||||
...context.repo,
|
...context.repo,
|
||||||
issue_number: context.payload.pull_request?.number as number,
|
issue_number: context.payload.pull_request?.number as number,
|
||||||
body: content
|
body: content
|
||||||
|
Loading…
x
Reference in New Issue
Block a user