File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1
1
const proc = require ( './processors' ) ;
2
+ const db = require ( '../db' ) ;
2
3
3
4
const pushActionChain = [
4
5
proc . push . parsePush ,
@@ -20,6 +21,22 @@ const pullActionChain = [proc.push.checkRepoInAuthorisedList];
20
21
21
22
let pluginsInserted = false ;
22
23
24
+ const attemptAutoApproval = async ( req , action ) => {
25
+ try {
26
+ const attestation = {
27
+ timestamp : new Date ( ) ,
28
+ autoApproved : true ,
29
+ } ;
30
+ await db . authorise ( action . id , attestation ) ;
31
+ console . log ( 'Push automatically approved by system.' ) ;
32
+
33
+ return true ;
34
+ } catch ( error ) {
35
+ console . error ( 'Error during auto-approval:' , error . message ) ;
36
+ return false ;
37
+ }
38
+ } ;
39
+
23
40
const executeChain = async ( req ) => {
24
41
let action ;
25
42
try {
@@ -40,6 +57,9 @@ const executeChain = async (req) => {
40
57
}
41
58
} finally {
42
59
await proc . push . audit ( req , action ) ;
60
+ if ( action . autoApproved ) {
61
+ attemptAutoApproval ( req , action ) ;
62
+ }
43
63
}
44
64
45
65
return action ;
You can’t perform that action at this time.
0 commit comments