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