fix: update test to include push event (#1173)

Co-authored-by: tj-actions[bot] <109116665+tj-actions-bot@users.noreply.github.com>
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Tonye Jack 2023-05-25 17:39:26 -06:00 committed by GitHub
parent 30e1bb07d4
commit abef388dd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 86 additions and 86 deletions

View File

@ -26,7 +26,6 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.event_name != 'push'
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
@ -50,6 +49,7 @@ jobs:
- name: Run eslint on changed files - name: Run eslint on changed files
uses: tj-actions/eslint-changed-files@v18 uses: tj-actions/eslint-changed-files@v18
if: github.event_name != 'push'
with: with:
token: ${{ secrets.PAT_TOKEN }} token: ${{ secrets.PAT_TOKEN }}
config_path: ".eslintrc.json" config_path: ".eslintrc.json"
@ -62,13 +62,14 @@ jobs:
- name: Verify Changed files - name: Verify Changed files
uses: tj-actions/verify-changed-files@v14 uses: tj-actions/verify-changed-files@v14
id: changed_files id: changed_files
if: github.event_name != 'push'
with: with:
files: | files: |
src src
dist dist
- name: Commit files - name: Commit files
if: steps.changed_files.outputs.files_changed == 'true' if: steps.changed_files.outputs.files_changed == 'true' && github.event_name != 'push'
run: | run: |
git config --local user.email "action@github.com" git config --local user.email "action@github.com"
git config --local user.name "GitHub Action" git config --local user.name "GitHub Action"
@ -76,7 +77,7 @@ jobs:
git commit -m "Added missing changes and modified dist assets." git commit -m "Added missing changes and modified dist assets."
- name: Push changes - name: Push changes
if: steps.changed_files.outputs.files_changed == 'true' if: steps.changed_files.outputs.files_changed == 'true' && github.event_name == 'pull_request'
uses: ad-m/github-push-action@master uses: ad-m/github-push-action@master
with: with:
github_token: ${{ secrets.PAT_TOKEN }} github_token: ${{ secrets.PAT_TOKEN }}
@ -1160,7 +1161,7 @@ jobs:
main-branch-name: ${{ steps.branch-name.outputs.base_ref_branch }} main-branch-name: ${{ steps.branch-name.outputs.base_ref_branch }}
workflow-id: 'test.yml' workflow-id: 'test.yml'
- name: Run changed-files with a custom base sha - name: Run changed-files with a custom base sha
if: github.event_name == 'pull_request' && github.event.action != 'closed' && matrix.fetch-depth == 0 if: github.event_name != 'push' && github.event.action != 'closed' && matrix.fetch-depth == 0
id: changed-files-custom-base-sha id: changed-files-custom-base-sha
uses: ./ uses: ./
with: with:

68
dist/index.js generated vendored
View File

@ -206,7 +206,7 @@ const getCurrentSHA = ({ inputs, workingDirectory }) => __awaiter(void 0, void 0
return currentSha; return currentSha;
}); });
const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodule, gitExtraArgs, isTag) => __awaiter(void 0, void 0, void 0, function* () { const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodule, gitExtraArgs, isTag) => __awaiter(void 0, void 0, void 0, function* () {
let targetBranch = env.GITHUB_REFNAME; let targetBranch = env.GITHUB_REF_NAME;
const currentBranch = targetBranch; const currentBranch = targetBranch;
let initialCommit = false; let initialCommit = false;
if (isShallow) { if (isShallow) {
@ -295,31 +295,31 @@ const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodu
targetBranch = tag; targetBranch = tag;
} }
else { else {
if (inputs.sinceLastRemoteCommit) {
core.debug('Getting previous SHA for last remote commit...'); core.debug('Getting previous SHA for last remote commit...');
if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) { if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) {
previousSha = env.GITHUB_EVENT_BEFORE; previousSha = env.GITHUB_EVENT_BEFORE;
} }
else { else {
previousSha = yield (0, utils_1.getParentHeadSha)({ cwd: workingDirectory }); previousSha = yield (0, utils_1.getParentSha)({
} cwd: workingDirectory
} });
else {
core.debug('Getting previous SHA for last commit...');
previousSha = yield (0, utils_1.getParentHeadSha)({ cwd: workingDirectory });
} }
if (!previousSha || if (!previousSha ||
previousSha === '0000000000000000000000000000000000000000') { previousSha === '0000000000000000000000000000000000000000') {
previousSha = yield (0, utils_1.getParentHeadSha)({ cwd: workingDirectory }); previousSha = yield (0, utils_1.getParentSha)({
cwd: workingDirectory
});
} }
if (previousSha === currentSha) { if (previousSha === currentSha) {
if (!(yield (0, utils_1.getParentHeadSha)({ cwd: workingDirectory }))) { if (!(yield (0, utils_1.getParentSha)({ cwd: workingDirectory }))) {
core.warning('Initial commit detected no previous commit found.'); core.warning('Initial commit detected no previous commit found.');
initialCommit = true; initialCommit = true;
previousSha = currentSha; previousSha = currentSha;
} }
else { else {
previousSha = yield (0, utils_1.getParentHeadSha)({ cwd: workingDirectory }); previousSha = yield (0, utils_1.getParentSha)({
cwd: workingDirectory
});
} }
} }
else { else {
@ -585,7 +585,7 @@ const getEnv = () => __awaiter(void 0, void 0, void 0, function* () {
GITHUB_EVENT_PULL_REQUEST_NUMBER: ((_f = eventJson.pull_request) === null || _f === void 0 ? void 0 : _f.number) || '', GITHUB_EVENT_PULL_REQUEST_NUMBER: ((_f = eventJson.pull_request) === null || _f === void 0 ? void 0 : _f.number) || '',
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ((_h = (_g = eventJson.pull_request) === null || _g === void 0 ? void 0 : _g.base) === null || _h === void 0 ? void 0 : _h.sha) || '', GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ((_h = (_g = eventJson.pull_request) === null || _g === void 0 ? void 0 : _g.base) === null || _h === void 0 ? void 0 : _h.sha) || '',
GITHUB_EVENT_FORCED: eventJson.forced || '', GITHUB_EVENT_FORCED: eventJson.forced || '',
GITHUB_REFNAME: process.env.GITHUB_REFNAME || '', GITHUB_REF_NAME: process.env.GITHUB_REF_NAME || '',
GITHUB_REF: process.env.GITHUB_REF || '', GITHUB_REF: process.env.GITHUB_REF || '',
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || '' GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || ''
}; };
@ -1160,7 +1160,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.setOutput = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentHeadSha = exports.gitLsRemote = exports.getHeadSha = exports.gitLog = exports.gitDiff = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.verifyMinimumGitVersion = void 0; exports.setOutput = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentSha = exports.gitLsRemote = exports.getHeadSha = exports.gitLog = exports.gitDiff = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.verifyMinimumGitVersion = void 0;
/*global AsyncIterableIterator*/ /*global AsyncIterableIterator*/
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514)); const exec = __importStar(__nccwpck_require__(1514));
@ -1234,7 +1234,7 @@ const versionToNumber = (version) => {
return major * 1000000 + minor * 1000 + patch; return major * 1000000 + minor * 1000 + patch;
}; };
const verifyMinimumGitVersion = () => __awaiter(void 0, void 0, void 0, function* () { const verifyMinimumGitVersion = () => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['--version'], { silent: false }); const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['--version'], { silent: process.env.ACTION_DEBUG === 'false' });
if (exitCode !== 0) { if (exitCode !== 0) {
throw new Error(stderr || 'An unexpected error occurred'); throw new Error(stderr || 'An unexpected error occurred');
} }
@ -1329,7 +1329,7 @@ const getFilesFromSourceFile = ({ filePaths, excludedFiles = false }) => __await
const updateGitGlobalConfig = ({ name, value }) => __awaiter(void 0, void 0, void 0, function* () { const updateGitGlobalConfig = ({ name, value }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stderr } = yield exec.getExecOutput('git', ['config', '--global', name, value], { const { exitCode, stderr } = yield exec.getExecOutput('git', ['config', '--global', name, value], {
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
/* istanbul ignore if */ /* istanbul ignore if */
if (exitCode !== 0 || stderr) { if (exitCode !== 0 || stderr) {
@ -1340,7 +1340,7 @@ exports.updateGitGlobalConfig = updateGitGlobalConfig;
const isRepoShallow = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { const isRepoShallow = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout } = yield exec.getExecOutput('git', ['rev-parse', '--is-shallow-repository'], { const { stdout } = yield exec.getExecOutput('git', ['rev-parse', '--is-shallow-repository'], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
return stdout.trim() === 'true'; return stdout.trim() === 'true';
}); });
@ -1349,7 +1349,7 @@ const submoduleExists = ({ cwd }) => __awaiter(void 0, void 0, void 0, function*
const { stdout, exitCode } = yield exec.getExecOutput('git', ['submodule', 'status'], { const { stdout, exitCode } = yield exec.getExecOutput('git', ['submodule', 'status'], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
if (exitCode !== 0) { if (exitCode !== 0) {
return false; return false;
@ -1361,7 +1361,7 @@ const gitFetch = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function*
const { exitCode } = yield exec.getExecOutput('git', ['fetch', '-q', ...args], { const { exitCode } = yield exec.getExecOutput('git', ['fetch', '-q', ...args], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
return exitCode; return exitCode;
}); });
@ -1370,7 +1370,7 @@ const gitFetchSubmodules = ({ args, cwd }) => __awaiter(void 0, void 0, void 0,
const { exitCode, stderr } = yield exec.getExecOutput('git', ['submodule', 'foreach', 'git', 'fetch', '-q', ...args], { const { exitCode, stderr } = yield exec.getExecOutput('git', ['submodule', 'foreach', 'git', 'fetch', '-q', ...args], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
/* istanbul ignore if */ /* istanbul ignore if */
if (exitCode !== 0) { if (exitCode !== 0) {
@ -1385,7 +1385,7 @@ const getSubmodulePath = ({ cwd }) => __awaiter(void 0, void 0, void 0, function
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['submodule', 'status'], { const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['submodule', 'status'], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
if (exitCode !== 0) { if (exitCode !== 0) {
core.warning(stderr || "Couldn't get submodule names"); core.warning(stderr || "Couldn't get submodule names");
@ -1401,7 +1401,7 @@ const gitSubmoduleDiffSHA = ({ cwd, parentSha1, parentSha2, submodulePath, diff
var _h, _j, _k, _l; var _h, _j, _k, _l;
const { stdout } = yield exec.getExecOutput('git', ['diff', parentSha1, parentSha2, '--', submodulePath], { const { stdout } = yield exec.getExecOutput('git', ['diff', parentSha1, parentSha2, '--', submodulePath], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
const subprojectCommitPreRegex = /^(?<preCommit>-)Subproject commit (?<commitHash>.+)$/m; const subprojectCommitPreRegex = /^(?<preCommit>-)Subproject commit (?<commitHash>.+)$/m;
const subprojectCommitCurRegex = /^(?<curCommit>\+)Subproject commit (?<commitHash>.+)$/m; const subprojectCommitCurRegex = /^(?<curCommit>\+)Subproject commit (?<commitHash>.+)$/m;
@ -1425,7 +1425,7 @@ const gitRenamedFiles = ({ cwd, sha1, sha2, diff, oldNewSeparator, isSubmodule =
], { ], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
if (exitCode !== 0) { if (exitCode !== 0) {
if (isSubmodule) { if (isSubmodule) {
@ -1463,7 +1463,7 @@ const gitDiff = ({ cwd, sha1, sha2, diff, diffFilter, filePatterns = [], isSubmo
], { ], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
if (exitCode !== 0) { if (exitCode !== 0) {
if (isSubmodule) { if (isSubmodule) {
@ -1498,7 +1498,7 @@ exports.gitDiff = gitDiff;
const gitLog = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () { const gitLog = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout } = yield exec.getExecOutput('git', ['log', ...args], { const { stdout } = yield exec.getExecOutput('git', ['log', ...args], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
return stdout.trim(); return stdout.trim();
}); });
@ -1506,7 +1506,7 @@ exports.gitLog = gitLog;
const getHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { const getHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout } = yield exec.getExecOutput('git', ['rev-parse', 'HEAD'], { const { stdout } = yield exec.getExecOutput('git', ['rev-parse', 'HEAD'], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
return stdout.trim(); return stdout.trim();
}); });
@ -1514,7 +1514,7 @@ exports.getHeadSha = getHeadSha;
const gitLsRemote = ({ cwd, args }) => __awaiter(void 0, void 0, void 0, function* () { const gitLsRemote = ({ cwd, args }) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout } = yield exec.getExecOutput('git', ['ls-remote', 'origin', ...args], { const { stdout } = yield exec.getExecOutput('git', ['ls-remote', 'origin', ...args], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
const output = stdout.trim().split('\t'); const output = stdout.trim().split('\t');
if (output.length === 0) { if (output.length === 0) {
@ -1523,19 +1523,19 @@ const gitLsRemote = ({ cwd, args }) => __awaiter(void 0, void 0, void 0, functio
return output[0]; return output[0];
}); });
exports.gitLsRemote = gitLsRemote; exports.gitLsRemote = gitLsRemote;
const getParentHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { const getParentSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout } = yield exec.getExecOutput('git', ['rev-parse', 'HEAD^'], { const { stdout } = yield exec.getExecOutput('git', ['rev-list', '-n', '1', 'HEAD^'], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
return stdout.trim(); return stdout.trim();
}); });
exports.getParentHeadSha = getParentHeadSha; exports.getParentSha = getParentSha;
const verifyCommitSha = ({ sha, cwd, showAsErrorMessage = true }) => __awaiter(void 0, void 0, void 0, function* () { const verifyCommitSha = ({ sha, cwd, showAsErrorMessage = true }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stderr } = yield exec.getExecOutput('git', ['rev-parse', '--verify', `${sha}^{commit}`], { const { exitCode, stderr } = yield exec.getExecOutput('git', ['rev-parse', '--verify', `${sha}^{commit}`], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
if (exitCode !== 0) { if (exitCode !== 0) {
if (showAsErrorMessage) { if (showAsErrorMessage) {
@ -1554,7 +1554,7 @@ exports.verifyCommitSha = verifyCommitSha;
const getPreviousGitTag = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { const getPreviousGitTag = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout } = yield exec.getExecOutput('git', ['tag', '--sort=-version:refname'], { const { stdout } = yield exec.getExecOutput('git', ['tag', '--sort=-version:refname'], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
const tags = stdout.trim().split('\n'); const tags = stdout.trim().split('\n');
if (tags.length < 2) { if (tags.length < 2) {
@ -1564,7 +1564,7 @@ const getPreviousGitTag = ({ cwd }) => __awaiter(void 0, void 0, void 0, functio
const previousTag = tags[1]; const previousTag = tags[1];
const { stdout: stdout2 } = yield exec.getExecOutput('git', ['rev-parse', previousTag], { const { stdout: stdout2 } = yield exec.getExecOutput('git', ['rev-parse', previousTag], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
const sha = stdout2.trim(); const sha = stdout2.trim();
return { tag: previousTag, sha }; return { tag: previousTag, sha };
@ -1574,7 +1574,7 @@ const canDiffCommits = ({ cwd, sha1, sha2, diff }) => __awaiter(void 0, void 0,
const { exitCode, stderr } = yield exec.getExecOutput('git', ['diff', '--name-only', '--ignore-submodules=all', `${sha1}${diff}${sha2}`], { const { exitCode, stderr } = yield exec.getExecOutput('git', ['diff', '--name-only', '--ignore-submodules=all', `${sha1}${diff}${sha2}`], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
if (exitCode !== 0) { if (exitCode !== 0) {
core.warning(stderr || `Unable find merge base between ${sha1} and ${sha2}`); core.warning(stderr || `Unable find merge base between ${sha1} and ${sha2}`);

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@ import {Inputs} from './inputs'
import { import {
canDiffCommits, canDiffCommits,
getHeadSha, getHeadSha,
getParentHeadSha, getParentSha,
getPreviousGitTag, getPreviousGitTag,
gitFetch, gitFetch,
gitFetchSubmodules, gitFetchSubmodules,
@ -74,7 +74,7 @@ export const getSHAForPushEvent = async (
gitExtraArgs: string[], gitExtraArgs: string[],
isTag: boolean isTag: boolean
): Promise<DiffResult> => { ): Promise<DiffResult> => {
let targetBranch = env.GITHUB_REFNAME let targetBranch = env.GITHUB_REF_NAME
const currentBranch = targetBranch const currentBranch = targetBranch
let initialCommit = false let initialCommit = false
@ -174,33 +174,33 @@ export const getSHAForPushEvent = async (
previousSha = sha previousSha = sha
targetBranch = tag targetBranch = tag
} else { } else {
if (inputs.sinceLastRemoteCommit) {
core.debug('Getting previous SHA for last remote commit...') core.debug('Getting previous SHA for last remote commit...')
if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) { if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) {
previousSha = env.GITHUB_EVENT_BEFORE previousSha = env.GITHUB_EVENT_BEFORE
} else { } else {
previousSha = await getParentHeadSha({cwd: workingDirectory}) previousSha = await getParentSha({
} cwd: workingDirectory
} else { })
core.debug('Getting previous SHA for last commit...')
previousSha = await getParentHeadSha({cwd: workingDirectory})
} }
if ( if (
!previousSha || !previousSha ||
previousSha === '0000000000000000000000000000000000000000' previousSha === '0000000000000000000000000000000000000000'
) { ) {
previousSha = await getParentHeadSha({cwd: workingDirectory}) previousSha = await getParentSha({
cwd: workingDirectory
})
} }
if (previousSha === currentSha) { if (previousSha === currentSha) {
if (!(await getParentHeadSha({cwd: workingDirectory}))) { if (!(await getParentSha({cwd: workingDirectory}))) {
core.warning('Initial commit detected no previous commit found.') core.warning('Initial commit detected no previous commit found.')
initialCommit = true initialCommit = true
previousSha = currentSha previousSha = currentSha
} else { } else {
previousSha = await getParentHeadSha({cwd: workingDirectory}) previousSha = await getParentSha({
cwd: workingDirectory
})
} }
} else { } else {
if (!previousSha) { if (!previousSha) {

View File

@ -5,7 +5,7 @@ export type Env = {
GITHUB_EVENT_PULL_REQUEST_HEAD_REF: string GITHUB_EVENT_PULL_REQUEST_HEAD_REF: string
GITHUB_EVENT_PULL_REQUEST_BASE_REF: string GITHUB_EVENT_PULL_REQUEST_BASE_REF: string
GITHUB_EVENT_BEFORE: string GITHUB_EVENT_BEFORE: string
GITHUB_REFNAME: string GITHUB_REF_NAME: string
GITHUB_REF: string GITHUB_REF: string
GITHUB_EVENT_BASE_REF: string GITHUB_EVENT_BASE_REF: string
GITHUB_EVENT_HEAD_REPO_FORK: string GITHUB_EVENT_HEAD_REPO_FORK: string
@ -41,7 +41,6 @@ export const getEnv = async (): Promise<Env> => {
if (eventPath) { if (eventPath) {
eventJson = JSON.parse(await fs.readFile(eventPath, {encoding: 'utf8'})) eventJson = JSON.parse(await fs.readFile(eventPath, {encoding: 'utf8'}))
} }
core.debug(`Event: ${JSON.stringify(eventJson, null, 2)}`) core.debug(`Event: ${JSON.stringify(eventJson, null, 2)}`)
return { return {
@ -53,7 +52,7 @@ export const getEnv = async (): Promise<Env> => {
GITHUB_EVENT_PULL_REQUEST_NUMBER: eventJson.pull_request?.number || '', GITHUB_EVENT_PULL_REQUEST_NUMBER: eventJson.pull_request?.number || '',
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: eventJson.pull_request?.base?.sha || '', GITHUB_EVENT_PULL_REQUEST_BASE_SHA: eventJson.pull_request?.base?.sha || '',
GITHUB_EVENT_FORCED: eventJson.forced || '', GITHUB_EVENT_FORCED: eventJson.forced || '',
GITHUB_REFNAME: process.env.GITHUB_REFNAME || '', GITHUB_REF_NAME: process.env.GITHUB_REF_NAME || '',
GITHUB_REF: process.env.GITHUB_REF || '', GITHUB_REF: process.env.GITHUB_REF || '',
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || '' GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || ''
} }

View File

@ -93,7 +93,7 @@ export const verifyMinimumGitVersion = async (): Promise<void> => {
const {exitCode, stdout, stderr} = await exec.getExecOutput( const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git', 'git',
['--version'], ['--version'],
{silent: false} {silent: process.env.ACTION_DEBUG === 'false'}
) )
if (exitCode !== 0) { if (exitCode !== 0) {
@ -177,7 +177,7 @@ export const updateGitGlobalConfig = async ({
['config', '--global', name, value], ['config', '--global', name, value],
{ {
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@ -193,7 +193,7 @@ export const isRepoShallow = async ({cwd}: {cwd: string}): Promise<boolean> => {
['rev-parse', '--is-shallow-repository'], ['rev-parse', '--is-shallow-repository'],
{ {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@ -211,7 +211,7 @@ export const submoduleExists = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@ -232,7 +232,7 @@ export const gitFetch = async ({
const {exitCode} = await exec.getExecOutput('git', ['fetch', '-q', ...args], { const {exitCode} = await exec.getExecOutput('git', ['fetch', '-q', ...args], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}) })
return exitCode return exitCode
@ -251,7 +251,7 @@ export const gitFetchSubmodules = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@ -276,7 +276,7 @@ export const getSubmodulePath = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@ -309,7 +309,7 @@ export const gitSubmoduleDiffSHA = async ({
['diff', parentSha1, parentSha2, '--', submodulePath], ['diff', parentSha1, parentSha2, '--', submodulePath],
{ {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@ -362,7 +362,7 @@ export const gitRenamedFiles = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@ -434,7 +434,7 @@ export const gitDiff = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@ -486,7 +486,7 @@ export const gitLog = async ({
}): Promise<string> => { }): Promise<string> => {
const {stdout} = await exec.getExecOutput('git', ['log', ...args], { const {stdout} = await exec.getExecOutput('git', ['log', ...args], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}) })
return stdout.trim() return stdout.trim()
@ -495,7 +495,7 @@ export const gitLog = async ({
export const getHeadSha = async ({cwd}: {cwd: string}): Promise<string> => { export const getHeadSha = async ({cwd}: {cwd: string}): Promise<string> => {
const {stdout} = await exec.getExecOutput('git', ['rev-parse', 'HEAD'], { const {stdout} = await exec.getExecOutput('git', ['rev-parse', 'HEAD'], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}) })
return stdout.trim() return stdout.trim()
@ -513,7 +513,7 @@ export const gitLsRemote = async ({
['ls-remote', 'origin', ...args], ['ls-remote', 'origin', ...args],
{ {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
const output = stdout.trim().split('\t') const output = stdout.trim().split('\t')
@ -525,15 +525,15 @@ export const gitLsRemote = async ({
return output[0] return output[0]
} }
export const getParentHeadSha = async ({ export const getParentSha = async ({cwd}: {cwd: string}): Promise<string> => {
cwd const {stdout} = await exec.getExecOutput(
}: { 'git',
cwd: string ['rev-list', '-n', '1', 'HEAD^'],
}): Promise<string> => { {
const {stdout} = await exec.getExecOutput('git', ['rev-parse', 'HEAD^'], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}) }
)
return stdout.trim() return stdout.trim()
} }
@ -553,7 +553,7 @@ export const verifyCommitSha = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@ -583,7 +583,7 @@ export const getPreviousGitTag = async ({
['tag', '--sort=-version:refname'], ['tag', '--sort=-version:refname'],
{ {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@ -601,7 +601,7 @@ export const getPreviousGitTag = async ({
['rev-parse', previousTag], ['rev-parse', previousTag],
{ {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@ -627,7 +627,7 @@ export const canDiffCommits = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )