Skip to content

Commit af74f3c

Browse files
committed
feat: push if autoApproved=true
1 parent cedeff6 commit af74f3c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/proxy/chain.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const proc = require('./processors');
2+
const db = require('../db');
23

34
const pushActionChain = [
45
proc.push.parsePush,
@@ -20,6 +21,22 @@ const pullActionChain = [proc.push.checkRepoInAuthorisedList];
2021

2122
let pluginsInserted = false;
2223

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+
2340
const executeChain = async (req) => {
2441
let action;
2542
try {
@@ -40,6 +57,9 @@ const executeChain = async (req) => {
4057
}
4158
} finally {
4259
await proc.push.audit(req, action);
60+
if (action.autoApproved) {
61+
attemptAutoApproval(req, action);
62+
}
4363
}
4464

4565
return action;

0 commit comments

Comments
 (0)