File tree 5 files changed +41
-8
lines changed
5 files changed +41
-8
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ describe('git', () => {
54
54
} )
55
55
56
56
await init ( action )
57
- expect ( execute ) . toHaveBeenCalledTimes ( 7 )
57
+ expect ( execute ) . toHaveBeenCalledTimes ( 8 )
58
58
} )
59
59
60
60
it ( 'should catch when a function throws an error' , async ( ) => {
@@ -101,7 +101,7 @@ describe('git', () => {
101
101
} )
102
102
103
103
await init ( action )
104
- expect ( execute ) . toHaveBeenCalledTimes ( 7 )
104
+ expect ( execute ) . toHaveBeenCalledTimes ( 8 )
105
105
} )
106
106
107
107
it ( 'should not unset git config if a user is using ssh' , async ( ) => {
@@ -123,7 +123,7 @@ describe('git', () => {
123
123
} )
124
124
125
125
await init ( action )
126
- expect ( execute ) . toHaveBeenCalledTimes ( 6 )
126
+ expect ( execute ) . toHaveBeenCalledTimes ( 7 )
127
127
128
128
process . env . CI = undefined
129
129
} )
@@ -144,7 +144,7 @@ describe('git', () => {
144
144
} )
145
145
146
146
await init ( action )
147
- expect ( execute ) . toHaveBeenCalledTimes ( 7 )
147
+ expect ( execute ) . toHaveBeenCalledTimes ( 8 )
148
148
} )
149
149
} )
150
150
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ describe('main', () => {
53
53
debug : true
54
54
} )
55
55
await run ( action )
56
- expect ( execute ) . toHaveBeenCalledTimes ( 18 )
56
+ expect ( execute ) . toHaveBeenCalledTimes ( 19 )
57
57
expect ( rmRF ) . toHaveBeenCalledTimes ( 1 )
58
58
expect ( exportVariable ) . toHaveBeenCalledTimes ( 1 )
59
59
} )
@@ -73,7 +73,7 @@ describe('main', () => {
73
73
isTest : TestFlag . HAS_CHANGED_FILES
74
74
} )
75
75
await run ( action )
76
- expect ( execute ) . toHaveBeenCalledTimes ( 21 )
76
+ expect ( execute ) . toHaveBeenCalledTimes ( 22 )
77
77
expect ( rmRF ) . toHaveBeenCalledTimes ( 1 )
78
78
expect ( exportVariable ) . toHaveBeenCalledTimes ( 1 )
79
79
} )
Original file line number Diff line number Diff line change 2
2
"name" : " @jamesives/github-pages-deploy-action" ,
3
3
"description" : " GitHub action for building a project and deploying it to GitHub pages." ,
4
4
"author" : " James Ives <iam@jamesiv.es> (https://jamesiv.es)" ,
5
- "version" : " 4.6.3 " ,
5
+ "version" : " 4.6.4 " ,
6
6
"license" : " MIT" ,
7
7
"main" : " lib/lib.js" ,
8
8
"types" : " lib/lib.d.ts" ,
Original file line number Diff line number Diff line change 1
1
import { exec } from '@actions/exec'
2
2
import buffer from 'buffer'
3
3
4
+ /**
5
+ * The output of a command.
6
+ */
4
7
type ExecuteOutput = {
8
+ /**
9
+ * The standard output of the command.
10
+ */
5
11
stdout : string
12
+ /**
13
+ * The standard error of the command.
14
+ */
6
15
stderr : string
7
16
}
8
17
@@ -21,7 +30,7 @@ export async function execute(
21
30
cmd : string ,
22
31
cwd : string ,
23
32
silent : boolean ,
24
- ignoreReturnCode = false
33
+ ignoreReturnCode : boolean = false
25
34
) : Promise < ExecuteOutput > {
26
35
output . stdout = ''
27
36
output . stderr = ''
@@ -37,6 +46,9 @@ export async function execute(
37
46
return Promise . resolve ( output )
38
47
}
39
48
49
+ /**
50
+ * Writes the output of a command to the stdout buffer.
51
+ */
40
52
export function stdout ( data : Buffer | string ) : void {
41
53
const dataString = data . toString ( ) . trim ( )
42
54
if (
@@ -47,6 +59,9 @@ export function stdout(data: Buffer | string): void {
47
59
}
48
60
}
49
61
62
+ /**
63
+ * Writes the output of a command to the stderr buffer.
64
+ */
50
65
export function stderr ( data : Buffer | string ) : void {
51
66
const dataString = data . toString ( ) . trim ( )
52
67
if (
Original file line number Diff line number Diff line change @@ -23,6 +23,24 @@ export async function init(action: ActionInterface): Promise<void | Error> {
23
23
info ( `Deploying using ${ action . tokenType } … 🔑` )
24
24
info ( 'Configuring git…' )
25
25
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
+ */
26
44
try {
27
45
await execute (
28
46
`git config --global --add safe.directory "${ action . workspace } "` ,
You can’t perform that action at this time.
0 commit comments