File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed 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