diff --git a/README.md b/README.md index 22e9a4994..b85967d31 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,8 @@ When Git 2.18 or higher is not in your PATH, falls back to the REST API to downl # The base URL for the GitHub instance that you are trying to clone from, will use # environment defaults to fetch from the same instance that the workflow is - # running from unless specified. + # running from unless specified. Example URLs are https://github.com or + # https://my-ghes-server.example.com github-server-url: '' ``` diff --git a/__test__/git-auth-helper.test.ts b/__test__/git-auth-helper.test.ts index adadd8b2c..2acec38f8 100644 --- a/__test__/git-auth-helper.test.ts +++ b/__test__/git-auth-helper.test.ts @@ -5,8 +5,8 @@ import * as io from '@actions/io' import * as os from 'os' import * as path from 'path' import * as stateHelper from '../lib/state-helper' -import { IGitCommandManager } from '../lib/git-command-manager' -import { IGitSourceSettings } from '../lib/git-source-settings' +import {IGitCommandManager} from '../lib/git-command-manager' +import {IGitSourceSettings} from '../lib/git-source-settings' const isWindows = process.platform === 'win32' const testWorkspace = path.join(__dirname, '_temp', 'git-auth-helper') @@ -17,7 +17,7 @@ let localGitConfigPath: string let globalGitConfigPath: string let runnerTemp: string let tempHomedir: string -let git: IGitCommandManager & { env: { [key: string]: string } } +let git: IGitCommandManager & {env: {[key: string]: string}} let settings: IGitSourceSettings let sshPath: string let githubServerUrl: string @@ -33,7 +33,7 @@ describe('git-auth-helper tests', () => { beforeEach(() => { // Mock setSecret - jest.spyOn(core, 'setSecret').mockImplementation((secret: string) => { }) + jest.spyOn(core, 'setSecret').mockImplementation((secret: string) => {}) // Mock error/warning/info/debug jest.spyOn(core, 'error').mockImplementation(jest.fn()) @@ -68,7 +68,10 @@ describe('git-auth-helper tests', () => { } }) - async function testAuthHeader(testName: string, serverUrl: string | undefined = undefined) { + async function testAuthHeader( + testName: string, + serverUrl: string | undefined = undefined + ) { // Arrange let expectedServerUrl = 'https://github.com' if (serverUrl) { @@ -101,17 +104,25 @@ describe('git-auth-helper tests', () => { const configureAuth_configuresAuthHeader = 'configureAuth configures auth header' it(configureAuth_configuresAuthHeader, async () => { - await testAuthHeader(configureAuth_configuresAuthHeader); + await testAuthHeader(configureAuth_configuresAuthHeader) }) - const configureAuth_AcceptsGitHubServerUrl = 'inject https://my-ghes-server.com as github server url' + const configureAuth_AcceptsGitHubServerUrl = + 'inject https://my-ghes-server.com as github server url' it(configureAuth_AcceptsGitHubServerUrl, async () => { - await testAuthHeader(configureAuth_AcceptsGitHubServerUrl, 'https://my-ghes-server.com'); + await testAuthHeader( + configureAuth_AcceptsGitHubServerUrl, + 'https://my-ghes-server.com' + ) }) - const configureAuth_AcceptsGitHubServerUrlSetToGHEC = 'inject https://github.com as github server url' + const configureAuth_AcceptsGitHubServerUrlSetToGHEC = + 'inject https://github.com as github server url' it(configureAuth_AcceptsGitHubServerUrlSetToGHEC, async () => { - await testAuthHeader(configureAuth_AcceptsGitHubServerUrl, 'https://github.com'); + await testAuthHeader( + configureAuth_AcceptsGitHubServerUrl, + 'https://github.com' + ) }) const configureAuth_configuresAuthHeaderEvenWhenPersistCredentialsFalse = @@ -699,9 +710,9 @@ async function setup(testName: string): Promise { workspace = path.join(testWorkspace, testName, 'workspace') runnerTemp = path.join(testWorkspace, testName, 'runner-temp') tempHomedir = path.join(testWorkspace, testName, 'home-dir') - await fs.promises.mkdir(workspace, { recursive: true }) - await fs.promises.mkdir(runnerTemp, { recursive: true }) - await fs.promises.mkdir(tempHomedir, { recursive: true }) + await fs.promises.mkdir(workspace, {recursive: true}) + await fs.promises.mkdir(runnerTemp, {recursive: true}) + await fs.promises.mkdir(tempHomedir, {recursive: true}) process.env['RUNNER_TEMP'] = runnerTemp process.env['HOME'] = tempHomedir @@ -709,7 +720,7 @@ async function setup(testName: string): Promise { globalGitConfigPath = path.join(tempHomedir, '.gitconfig') await fs.promises.writeFile(globalGitConfigPath, '') localGitConfigPath = path.join(workspace, '.git', 'config') - await fs.promises.mkdir(path.dirname(localGitConfigPath), { recursive: true }) + await fs.promises.mkdir(path.dirname(localGitConfigPath), {recursive: true}) await fs.promises.writeFile(localGitConfigPath, '') git = { diff --git a/action.yml b/action.yml index 12c5f4c48..cab09ebd3 100644 --- a/action.yml +++ b/action.yml @@ -72,7 +72,7 @@ inputs: description: Add repository path as safe.directory for Git global config by running `git config --global --add safe.directory ` default: true github-server-url: - description: The base URL for the GitHub instance that you are trying to clone from, will use environment defaults to fetch from the same instance that the workflow is running from unless specified. + description: The base URL for the GitHub instance that you are trying to clone from, will use environment defaults to fetch from the same instance that the workflow is running from unless specified. Example URLs are https://github.com or https://my-ghes-server.example.com required: false runs: using: node16 diff --git a/dist/index.js b/dist/index.js index edde37e02..d1ed5f972 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1295,51 +1295,6 @@ module.exports._parse = parse; module.exports._enoent = enoent; -/***/ }), - -/***/ 24: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getOctokit = exports.Octokit = void 0; -const github = __importStar(__webpack_require__(469)); -const url_helper_1 = __webpack_require__(81); -// Centralize all Octokit references by re-exporting -var rest_1 = __webpack_require__(0); -Object.defineProperty(exports, "Octokit", { enumerable: true, get: function () { return rest_1.Octokit; } }); -function getOctokit(authToken, opts) { - const options = { - baseUrl: (0, url_helper_1.getServerApiUrl)(opts.baseUrl) - }; - if (opts.userAgent) { - options.userAgent = opts.userAgent; - } - return new github.GitHub(authToken, options); -} -exports.getOctokit = getOctokit; - - /***/ }), /***/ 26: @@ -4125,6 +4080,51 @@ function authenticationPlugin(octokit, options) { } +/***/ }), + +/***/ 195: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getOctokit = exports.Octokit = void 0; +const github = __importStar(__webpack_require__(469)); +const url_helper_1 = __webpack_require__(81); +// Centralize all Octokit references by re-exporting +var rest_1 = __webpack_require__(0); +Object.defineProperty(exports, "Octokit", { enumerable: true, get: function () { return rest_1.Octokit; } }); +function getOctokit(authToken, opts) { + const options = { + baseUrl: (0, url_helper_1.getServerApiUrl)(opts.baseUrl) + }; + if (opts.userAgent) { + options.userAgent = opts.userAgent; + } + return new github.GitHub(authToken, options); +} +exports.getOctokit = getOctokit; + + /***/ }), /***/ 197: @@ -4340,7 +4340,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.checkCommitInfo = exports.testRef = exports.getRefSpec = exports.getRefSpecForAllHistory = exports.getCheckoutInfo = exports.tagsRefSpec = void 0; const core = __importStar(__webpack_require__(470)); const github = __importStar(__webpack_require__(469)); -const octokit_helper_1 = __webpack_require__(24); +const octokit_provider_1 = __webpack_require__(195); const url_helper_1 = __webpack_require__(81); exports.tagsRefSpec = '+refs/tags/*:refs/tags/*'; function getCheckoutInfo(git, ref, commit) { @@ -4541,7 +4541,7 @@ function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref const actualHeadSha = match[1]; if (actualHeadSha !== expectedHeadSha) { core.debug(`Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`); - const octokit = (0, octokit_helper_1.getOctokit)(token, { + const octokit = (0, octokit_provider_1.getOctokit)(token, { baseUrl: baseUrl, userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload('number')};run_id=${process.env['GITHUB_RUN_ID']};expected_head_sha=${expectedHeadSha};actual_head_sha=${actualHeadSha})` }); @@ -11028,7 +11028,7 @@ const path = __importStar(__webpack_require__(622)); const retryHelper = __importStar(__webpack_require__(587)); const toolCache = __importStar(__webpack_require__(533)); const v4_1 = __importDefault(__webpack_require__(826)); -const octokit_helper_1 = __webpack_require__(24); +const octokit_provider_1 = __webpack_require__(195); const IS_WINDOWS = process.platform === 'win32'; function downloadRepository(authToken, owner, repo, ref, commit, repositoryPath, baseUrl) { return __awaiter(this, void 0, void 0, function* () { @@ -11089,7 +11089,7 @@ function getDefaultBranch(authToken, owner, repo, baseUrl) { return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { var _a; core.info('Retrieving the default branch name'); - const octokit = (0, octokit_helper_1.getOctokit)(authToken, { baseUrl: baseUrl }); + const octokit = (0, octokit_provider_1.getOctokit)(authToken, { baseUrl: baseUrl }); let result; try { // Get the default branch from the repo info @@ -11121,7 +11121,7 @@ function getDefaultBranch(authToken, owner, repo, baseUrl) { exports.getDefaultBranch = getDefaultBranch; function downloadArchive(authToken, owner, repo, ref, commit, baseUrl) { return __awaiter(this, void 0, void 0, function* () { - const octokit = (0, octokit_helper_1.getOctokit)(authToken, { baseUrl: baseUrl }); + const octokit = (0, octokit_provider_1.getOctokit)(authToken, { baseUrl: baseUrl }); const params = { owner: owner, repo: repo, diff --git a/src/github-api-helper.ts b/src/github-api-helper.ts index 5c0ee1e03..2124a869b 100644 --- a/src/github-api-helper.ts +++ b/src/github-api-helper.ts @@ -6,7 +6,7 @@ import * as path from 'path' import * as retryHelper from './retry-helper' import * as toolCache from '@actions/tool-cache' import {default as uuid} from 'uuid/v4' -import {getOctokit, Octokit} from './octokit-helper' +import {getOctokit, Octokit} from './octokit-provider' const IS_WINDOWS = process.platform === 'win32' diff --git a/src/octokit-helper.ts b/src/octokit-provider.ts similarity index 100% rename from src/octokit-helper.ts rename to src/octokit-provider.ts diff --git a/src/ref-helper.ts b/src/ref-helper.ts index 823f929e5..ce875fc09 100644 --- a/src/ref-helper.ts +++ b/src/ref-helper.ts @@ -1,7 +1,7 @@ import {IGitCommandManager} from './git-command-manager' import * as core from '@actions/core' import * as github from '@actions/github' -import {getOctokit} from './octokit-helper' +import {getOctokit} from './octokit-provider' import {isGhes} from './url-helper' export const tagsRefSpec = '+refs/tags/*:refs/tags/*'