Skip to content

Commit c30eaca

Browse files
committed
Merge branch 'dev' into releases/v4
2 parents 920cbb3 + dd28e19 commit c30eaca

File tree

5 files changed

+41
-8
lines changed

5 files changed

+41
-8
lines changed

__tests__/git.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('git', () => {
5454
})
5555

5656
await init(action)
57-
expect(execute).toHaveBeenCalledTimes(7)
57+
expect(execute).toHaveBeenCalledTimes(8)
5858
})
5959

6060
it('should catch when a function throws an error', async () => {
@@ -101,7 +101,7 @@ describe('git', () => {
101101
})
102102

103103
await init(action)
104-
expect(execute).toHaveBeenCalledTimes(7)
104+
expect(execute).toHaveBeenCalledTimes(8)
105105
})
106106

107107
it('should not unset git config if a user is using ssh', async () => {
@@ -123,7 +123,7 @@ describe('git', () => {
123123
})
124124

125125
await init(action)
126-
expect(execute).toHaveBeenCalledTimes(6)
126+
expect(execute).toHaveBeenCalledTimes(7)
127127

128128
process.env.CI = undefined
129129
})
@@ -144,7 +144,7 @@ describe('git', () => {
144144
})
145145

146146
await init(action)
147-
expect(execute).toHaveBeenCalledTimes(7)
147+
expect(execute).toHaveBeenCalledTimes(8)
148148
})
149149
})
150150

__tests__/main.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('main', () => {
5353
debug: true
5454
})
5555
await run(action)
56-
expect(execute).toHaveBeenCalledTimes(18)
56+
expect(execute).toHaveBeenCalledTimes(19)
5757
expect(rmRF).toHaveBeenCalledTimes(1)
5858
expect(exportVariable).toHaveBeenCalledTimes(1)
5959
})
@@ -73,7 +73,7 @@ describe('main', () => {
7373
isTest: TestFlag.HAS_CHANGED_FILES
7474
})
7575
await run(action)
76-
expect(execute).toHaveBeenCalledTimes(21)
76+
expect(execute).toHaveBeenCalledTimes(22)
7777
expect(rmRF).toHaveBeenCalledTimes(1)
7878
expect(exportVariable).toHaveBeenCalledTimes(1)
7979
})

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@jamesives/github-pages-deploy-action",
33
"description": "GitHub action for building a project and deploying it to GitHub pages.",
44
"author": "James Ives <iam@jamesiv.es> (https://jamesiv.es)",
5-
"version": "4.6.3",
5+
"version": "4.6.4",
66
"license": "MIT",
77
"main": "lib/lib.js",
88
"types": "lib/lib.d.ts",

src/execute.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
import {exec} from '@actions/exec'
22
import buffer from 'buffer'
33

4+
/**
5+
* The output of a command.
6+
*/
47
type ExecuteOutput = {
8+
/**
9+
* The standard output of the command.
10+
*/
511
stdout: string
12+
/**
13+
* The standard error of the command.
14+
*/
615
stderr: string
716
}
817

@@ -21,7 +30,7 @@ export async function execute(
2130
cmd: string,
2231
cwd: string,
2332
silent: boolean,
24-
ignoreReturnCode = false
33+
ignoreReturnCode: boolean = false
2534
): Promise<ExecuteOutput> {
2635
output.stdout = ''
2736
output.stderr = ''
@@ -37,6 +46,9 @@ export async function execute(
3746
return Promise.resolve(output)
3847
}
3948

49+
/**
50+
* Writes the output of a command to the stdout buffer.
51+
*/
4052
export function stdout(data: Buffer | string): void {
4153
const dataString = data.toString().trim()
4254
if (
@@ -47,6 +59,9 @@ export function stdout(data: Buffer | string): void {
4759
}
4860
}
4961

62+
/**
63+
* Writes the output of a command to the stderr buffer.
64+
*/
5065
export function stderr(data: Buffer | string): void {
5166
const dataString = data.toString().trim()
5267
if (

src/git.ts

+18
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,24 @@ export async function init(action: ActionInterface): Promise<void | Error> {
2323
info(`Deploying using ${action.tokenType}… 🔑`)
2424
info('Configuring git…')
2525

26+
/**
27+
* Add safe directory to the global git config.
28+
*/
29+
try {
30+
await execute(
31+
`git config --global safe.directory '*'`,
32+
action.workspace,
33+
action.silent
34+
)
35+
} catch {
36+
info('Unable to set workflow file tree as a safe directory…')
37+
}
38+
39+
/**
40+
* Ensure that the workspace is a safe directory, this is somewhat redundant as the action
41+
* will always set the workspace as a safe directory, but this is a fallback in case the action
42+
* fails to do so.
43+
*/
2644
try {
2745
await execute(
2846
`git config --global --add safe.directory "${action.workspace}"`,

0 commit comments

Comments
 (0)