mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2026-05-31 00:12:03 +08:00
fix: issue with failing checkout
This commit is contained in:
@@ -54,7 +54,7 @@ describe('git', () => {
|
||||
})
|
||||
|
||||
await init(action)
|
||||
expect(execute).toHaveBeenCalledTimes(9)
|
||||
expect(execute).toHaveBeenCalledTimes(10)
|
||||
})
|
||||
|
||||
it('should catch when a function throws an error', async () => {
|
||||
@@ -101,7 +101,7 @@ describe('git', () => {
|
||||
})
|
||||
|
||||
await init(action)
|
||||
expect(execute).toHaveBeenCalledTimes(9)
|
||||
expect(execute).toHaveBeenCalledTimes(10)
|
||||
})
|
||||
|
||||
it('should not unset git config if a user is using ssh', async () => {
|
||||
@@ -144,7 +144,7 @@ describe('git', () => {
|
||||
})
|
||||
|
||||
await init(action)
|
||||
expect(execute).toHaveBeenCalledTimes(9)
|
||||
expect(execute).toHaveBeenCalledTimes(10)
|
||||
})
|
||||
|
||||
it('should remove includeIf git config sections when present', async () => {
|
||||
@@ -168,6 +168,7 @@ describe('git', () => {
|
||||
})
|
||||
.mockImplementationOnce(() => ({stdout: '', stderr: ''})) // remove-section includeIf --local
|
||||
.mockImplementationOnce(() => ({stdout: '', stderr: ''})) // git config --global --get-regexp includeIf
|
||||
.mockImplementationOnce(() => ({stdout: '', stderr: ''})) // git config --system --get-regexp includeIf
|
||||
.mockImplementationOnce(() => ({stdout: '', stderr: ''})) // git remote rm
|
||||
.mockImplementationOnce(() => ({stdout: '', stderr: ''})) // git remote add
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ describe('main', () => {
|
||||
debug: true
|
||||
})
|
||||
await run(action)
|
||||
expect(execute).toHaveBeenCalledTimes(21)
|
||||
expect(execute).toHaveBeenCalledTimes(22)
|
||||
expect(rmRF).toHaveBeenCalledTimes(1)
|
||||
expect(exportVariable).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
@@ -73,7 +73,7 @@ describe('main', () => {
|
||||
isTest: TestFlag.HAS_CHANGED_FILES
|
||||
})
|
||||
await run(action)
|
||||
expect(execute).toHaveBeenCalledTimes(24)
|
||||
expect(execute).toHaveBeenCalledTimes(25)
|
||||
expect(rmRF).toHaveBeenCalledTimes(1)
|
||||
expect(exportVariable).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
@@ -78,12 +78,14 @@ export async function init(action: ActionInterface): Promise<void | Error> {
|
||||
|
||||
// Remove includeIf directives that point to credential files (actions/checkout@v6+)
|
||||
try {
|
||||
if ((process.env.CI && !action.sshKey) || action.isTest) {
|
||||
// Always try to remove includeIf credentials when not using SSH key
|
||||
// This is necessary because actions/checkout@v6+ uses includeIf to inject credentials
|
||||
if (!action.sshKey || action.isTest) {
|
||||
/* actions/checkout@v6+ uses includeIf directives to inject credentials.
|
||||
We need to remove these to ensure the provided token/SSH key is used instead.
|
||||
Check both local and global scopes as containers may configure differently.
|
||||
Check local, global, and system scopes as containers may configure differently.
|
||||
*/
|
||||
for (const scope of ['--local', '--global']) {
|
||||
for (const scope of ['--local', '--global', '--system']) {
|
||||
try {
|
||||
const includeIfResult = await execute(
|
||||
`git config ${scope} --get-regexp 'includeIf\\..*\\.path'`,
|
||||
|
||||
Reference in New Issue
Block a user