@@ -6,6 +6,35 @@ import 'zx/globals'
6
6
7
7
/* global $ */
8
8
$ . verbose = false
9
+ const retryLimit = 10
10
+
11
+ const getResult = async ( context , token , branch , repo , files , message , tag , count ) => {
12
+ if ( ! count ) count = 0
13
+ try {
14
+ const result = await commit (
15
+ {
16
+ token,
17
+ branch,
18
+ owner : repo [ 0 ] ,
19
+ repo : repo [ 1 ] ,
20
+ } ,
21
+ files ,
22
+ message ,
23
+ tag
24
+ )
25
+ echo `${ JSON . stringify ( { result, context, branch, repo, message, tag } , undefined , 2 ) } `
26
+ return result
27
+ } catch ( error ) {
28
+ if ( error . message === 'Update is not a fast forward' && count <= retryLimit ) {
29
+ count ++
30
+ return await getResult ( context , token , branch , repo , files , message , tag , count )
31
+ } else if ( error . message === 'Update is not a fast forward' ) {
32
+ throw new Error ( 'Update is not a fast forward, retry limit reached.' )
33
+ } else {
34
+ throw error
35
+ }
36
+ }
37
+ }
9
38
10
39
try {
11
40
const filesInput = core . getInput ( 'files' )
16
45
const branch = core . getInput ( 'ref' ) || context . github . ref_name
17
46
const tag = core . getInput ( 'tag' ) || false
18
47
const files = await getFiles ( filesInput )
19
- const result = await commit (
20
- {
21
- token,
22
- branch,
23
- owner : repo [ 0 ] ,
24
- repo : repo [ 1 ] ,
25
- } ,
26
- files ,
27
- message ,
28
- tag
29
- )
30
- echo `${ JSON . stringify ( { result, context, branch, repo, message, tag } , undefined , 2 ) } `
48
+ const result = await getResult ( context , token , branch , repo , files , message , tag )
31
49
core . setOutput ( 'sha' , result . object ?. sha )
32
50
} catch ( error ) {
33
51
core . setFailed ( error . message )
0 commit comments