diff --git a/apps/affected/src/main.ts b/apps/affected/src/main.ts index 501345b..23cb2b4 100644 --- a/apps/affected/src/main.ts +++ b/apps/affected/src/main.ts @@ -8,7 +8,11 @@ import { AST } from './parser.types'; export const getImageName = (appTarget: string, hasChanges: boolean, sha: string, productionBranch?: string, imageTagPrefix?: string) => { - const baseRef = process.env.BASE_REF || github.context.payload?.pull_request?.base?.ref || process.env.GITHUB_REF_NAME; + let baseRef = process.env.BASE_REF || github.context.payload?.pull_request?.base?.ref || process.env.GITHUB_REF_NAME; + + if (baseRef && baseRef.includes('/')) { + baseRef = baseRef.split('/').pop(); + } let imageName1 = `${appTarget}:${baseRef}-${sha}`; if (!hasChanges) { diff --git a/dist/apps/affected/main.js b/dist/apps/affected/main.js index 67c4822..371b480 100644 --- a/dist/apps/affected/main.js +++ b/dist/apps/affected/main.js @@ -73,6 +73,6 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``)}_.g `,!1),XE=vA("\r",!1),wo=Dy(),ey=vA("#",!1),ty=vA("/*",!1),Gi=vA("*/",!1),ry=function(E,C){return[E,...C.map(([,d])=>d)]},sy=function(E,C){return{type:"STATEMENT",key:E,value:C}},oy=function(E,C){return C?{type:"EXPRESSION_WITH_EXCEPT",base:E,excludes:C}:E},ny=function(E,C){let d=[E],I=[];for(let b=0;bd)]},Cy=function(E,C,d){return{type:"QUOTE_LITERAL",value:E.join(""),...C?{ignoreCase:!0}:{},...d?{suffix:d}:{}}},By=function(E,C,d){return{type:"QUOTE_LITERAL",value:E.join(""),...C?{ignoreCase:!0}:{},...d?{suffix:d}:{}}},hy=function(E,C,d){return{type:"REGEX_LITERAL",pattern:E.join(""),...C&&C.length>0?{flags:C.join("")}:{},...d?{suffix:d}:{}}},Iy=function(E){return{type:"STATEMENT_REF",value:E.join("")}},dy=function(E){return{name:E,path:E}},fy=function(E){return{name:E}},py=function(E,C){return E+C.join("")},yy=function(){return!0},my=function(E){return E.toUpperCase()},wy=function(E){return E},Ry=function(E){return E},Q=e.peg$currPos|0,gA=Q,Ir=[{line:1,column:1}],Pe=Q,Ro=e.peg$maxFailExpected||[],N=e.peg$silentFails|0,ds;if(e.startRule){if(!(e.startRule in s))throw new Error(`Can't start parsing from rule "`+e.startRule+'".');o=s[e.startRule]}function RM(){return A.substring(gA,Q)}function DM(){return gA}function bM(){return{source:r,start:gA,end:Q}}function kM(){return fs(gA,Q)}function FM(E,C){throw C=C!==void 0?C:fs(gA,Q),zE([ZE(E)],A.substring(gA,Q),C)}function SM(E,C){throw C=C!==void 0?C:fs(gA,Q),ky(E,C)}function vA(E,C){return{type:"literal",text:E,ignoreCase:C}}function qe(E,C,d){return{type:"class",parts:E,inverted:C,ignoreCase:d}}function Dy(){return{type:"any"}}function by(){return{type:"end"}}function ZE(E){return{type:"other",description:E}}function KE(E){var C=Ir[E],d;if(C)return C;if(E>=Ir.length)d=Ir.length-1;else for(d=E;!Ir[--d];);for(C=Ir[d],C={line:C.line,column:C.column};dPe&&(Pe=Q,Ro=[]),Ro.push(E))}function ky(E,C){return new Br(E,null,null,C)}function zE(E,C,d){return new Br(Br.buildMessage(E,C),E,C,d)}function $E(){var E;return E=Fy(),E}function Fy(){var E,C,d,I,F,b,pA,hA;if(E=Q,C=RA(),d=vi(),d!==t){for(I=RA(),F=[],b=Q,pA=RA(),hA=vi(),hA!==t?(pA=[pA,hA],b=pA):(Q=b,b=t);b!==t;)F.push(b),b=Q,pA=RA(),hA=vi(),hA!==t?(pA=[pA,hA],b=pA):(Q=b,b=t);b=RA(),gA=E,E=ry(d,F)}else Q=E,E=t;return E}function vi(){var E,C,d,I,F,b;return E=Q,C=xy(),C!==t?(d=RA(),I=Mi(),I!==t?(F=RA(),A.charCodeAt(Q)===59?(b=n,Q++):(b=t,N===0&&G(ue)),b!==t?(gA=E,E=sy(C,I)):(Q=E,E=t)):(Q=E,E=t)):(Q=E,E=t),E}function Mi(){var E,C,d;return E=Q,C=Sy(),C!==t?(d=Ny(),d===t&&(d=null),gA=E,E=oy(C,d)):(Q=E,E=t),E}function Sy(){var E,C,d,I,F,b,pA,hA;if(E=Q,C=xi(),C!==t){for(d=[],I=Q,F=RA(),b=Al(),b===t&&(b=null),pA=RA(),hA=xi(),hA!==t?(F=[F,b,pA,hA],I=F):(Q=I,I=t);I!==t;)d.push(I),I=Q,F=RA(),b=Al(),b===t&&(b=null),pA=RA(),hA=xi(),hA!==t?(F=[F,b,pA,hA],I=F):(Q=I,I=t);gA=E,E=ny(C,d)}else Q=E,E=t;return E}function xi(){var E,C,d,I,F,b,pA,hA;return E=Q,A.charCodeAt(Q)===33?(C=i,Q++):(C=t,N===0&&G(Tt)),C!==t?(d=RA(),A.charCodeAt(Q)===40?(I=a,Q++):(I=t,N===0&&G(BA)),I!==t?(F=RA(),b=Mi(),b!==t?(pA=RA(),A.charCodeAt(Q)===41?(hA=c,Q++):(hA=t,N===0&&G(UA)),hA!==t?(gA=E,E=iy(b)):(Q=E,E=t)):(Q=E,E=t)):(Q=E,E=t)):(Q=E,E=t),E===t&&(E=Q,A.charCodeAt(Q)===40?(C=a,Q++):(C=t,N===0&&G(BA)),C!==t?(d=RA(),I=Mi(),I!==t?(F=RA(),A.charCodeAt(Q)===41?(b=c,Q++):(b=t,N===0&&G(UA)),b!==t?(gA=E,E=ay(I)):(Q=E,E=t)):(Q=E,E=t)):(Q=E,E=t),E===t&&(E=Ty())),E}function Al(){var E,C;return E=Q,C=A.substr(Q,3),C.toLowerCase()===g?Q+=3:(C=t,N===0&&G(V)),C!==t&&(gA=E,C=cy()),E=C,E===t&&(E=Q,C=A.substr(Q,2),C.toLowerCase()===l?Q+=2:(C=t,N===0&&G(Qt)),C!==t&&(gA=E,C=gy()),E=C),E}function Ty(){var E,C,d,I;return E=Q,C=ps(),C!==t&&(gA=E,C=Ey(C)),E=C,E===t&&(E=Q,A.charCodeAt(Q)===33?(C=i,Q++):(C=t,N===0&&G(Tt)),C!==t?(d=RA(),I=ps(),I!==t?(gA=E,E=ly(I)):(Q=E,E=t)):(Q=E,E=t)),E}function ps(){var E;return E=Ly(),E===t&&(E=Gy(),E===t&&(E=vy(),E===t&&(E=My()))),E}function Ny(){var E,C,d,I,F,b,pA,hA,ze;return E=Q,C=RA(),d=A.substr(Q,6),d.toLowerCase()===u?Q+=6:(d=t,N===0&&G(Ui)),d!==t?(I=RA(),A.charCodeAt(Q)===40?(F=a,Q++):(F=t,N===0&&G(BA)),F!==t?(b=RA(),pA=Uy(),pA!==t?(hA=RA(),A.charCodeAt(Q)===41?(ze=c,Q++):(ze=t,N===0&&G(UA)),ze!==t?(gA=E,E=uy(pA)):(Q=E,E=t)):(Q=E,E=t)):(Q=E,E=t)):(Q=E,E=t),E}function Uy(){var E,C,d,I,F,b;if(E=Q,C=ps(),C!==t){for(d=[],I=Q,F=RA(),b=ps(),b!==t?(F=[F,b],I=F):(Q=I,I=t);I!==t;)d.push(I),I=Q,F=RA(),b=ps(),b!==t?(F=[F,b],I=F):(Q=I,I=t);gA=E,E=Qy(C,d)}else Q=E,E=t;return E}function Ly(){var E,C,d,I,F,b;if(E=Q,A.charCodeAt(Q)===39?(C=h,Q++):(C=t,N===0&&G(L)),C!==t){for(d=[],I=A.charAt(Q),y.test(I)?Q++:(I=t,N===0&&G(QA));I!==t;)d.push(I),I=A.charAt(Q),y.test(I)?Q++:(I=t,N===0&&G(QA));A.charCodeAt(Q)===39?(I=h,Q++):(I=t,N===0&&G(L)),I!==t?(F=tl(),F===t&&(F=null),b=_i(),b===t&&(b=null),gA=E,E=Cy(d,F,b)):(Q=E,E=t)}else Q=E,E=t;return E}function Gy(){var E,C,d,I,F,b;if(E=Q,A.charCodeAt(Q)===34?(C=B,Q++):(C=t,N===0&&G(T)),C!==t){for(d=[],I=A.charAt(Q),iA.test(I)?Q++:(I=t,N===0&&G(z));I!==t;)d.push(I),I=A.charAt(Q),iA.test(I)?Q++:(I=t,N===0&&G(z));A.charCodeAt(Q)===34?(I=B,Q++):(I=t,N===0&&G(T)),I!==t?(F=tl(),F===t&&(F=null),b=_i(),b===t&&(b=null),gA=E,E=By(d,F,b)):(Q=E,E=t)}else Q=E,E=t;return E}function vy(){var E,C,d,I,F,b;return E=Q,A.charCodeAt(Q)===47?(C=w,Q++):(C=t,N===0&&G(fA)),C!==t?(d=Jy(),d!==t?(A.charCodeAt(Q)===47?(I=w,Q++):(I=t,N===0&&G(fA)),I!==t?(F=Hy(),F===t&&(F=null),b=_i(),b===t&&(b=null),gA=E,E=hy(d,F,b)):(Q=E,E=t)):(Q=E,E=t)):(Q=E,E=t),E}function My(){var E,C,d,I;if(E=Q,C=Q,N++,d=A.substr(Q,3),d.toLowerCase()===g?Q+=3:(d=t,N===0&&G(V)),d===t&&(d=A.substr(Q,2),d.toLowerCase()===l?Q+=2:(d=t,N===0&&G(Qt)),d===t&&(d=A.substr(Q,6),d.toLowerCase()===u?Q+=6:(d=t,N===0&&G(WA)))),N--,d===t?C=void 0:(Q=C,C=t),C!==t){if(d=[],I=A.charAt(Q),Y.test(I)?Q++:(I=t,N===0&&G(FA)),I!==t)for(;I!==t;)d.push(I),I=A.charAt(Q),Y.test(I)?Q++:(I=t,N===0&&G(FA));else d=t;d!==t?(gA=E,E=Iy(d)):(Q=E,E=t)}else Q=E,E=t;return E}function xy(){var E;return E=_y(),E===t&&(E=Yy()),E}function _y(){var E,C,d,I,F,b;return E=Q,A.charCodeAt(Q)===60?(C=R,Q++):(C=t,N===0&&G(Is)),C!==t?(d=el(),d!==t?(A.charCodeAt(Q)===62?(I=k,Q++):(I=t,N===0&&G(hr)),I!==t?(F=RA(),A.charCodeAt(Q)===58?(b=D,Q++):(b=t,N===0&&G(Li)),b!==t?(gA=E,E=dy(d)):(Q=E,E=t)):(Q=E,E=t)):(Q=E,E=t)):(Q=E,E=t),E}function Yy(){var E,C,d,I;return E=Q,C=el(),C!==t?(d=RA(),A.charCodeAt(Q)===58?(I=D,Q++):(I=t,N===0&&G(Li)),I!==t?(gA=E,E=fy(C)):(Q=E,E=t)):(Q=E,E=t),E}function el(){var E,C,d,I,F;if(E=Q,C=Q,N++,d=A.charAt(Q),X.test(d)?Q++:(d=t,N===0&&G(Xp)),N--,d===t?C=void 0:(Q=C,C=t),C!==t)if(d=A.charAt(Q),f.test(d)?Q++:(d=t,N===0&&G(Zp)),d!==t){for(I=[],F=A.charAt(Q),Y.test(F)?Q++:(F=t,N===0&&G(FA));F!==t;)I.push(F),F=A.charAt(Q),Y.test(F)?Q++:(F=t,N===0&&G(FA));gA=E,E=py(d,I)}else Q=E,E=t;else Q=E,E=t;return E}function tl(){var E,C;return E=Q,C=A.charAt(Q),m.test(C)?Q++:(C=t,N===0&&G(Kp)),C!==t&&(gA=E,C=yy()),E=C,E}function _i(){var E,C,d;return E=Q,A.charCodeAt(Q)===58?(C=D,Q++):(C=t,N===0&&G(Li)),C!==t?(d=A.charAt(Q),uA.test(d)?Q++:(d=t,N===0&&G(zp)),d!==t?(gA=E,E=my(d)):(Q=E,E=t)):(Q=E,E=t),E}function Jy(){var E,C,d;if(E=Q,C=[],d=A.charAt(Q),rA.test(d)?Q++:(d=t,N===0&&G(PE)),d!==t)for(;d!==t;)C.push(d),d=A.charAt(Q),rA.test(d)?Q++:(d=t,N===0&&G(PE));else C=t;return C!==t&&(gA=E,C=wy(C)),E=C,E}function Hy(){var E,C,d;if(E=Q,C=[],d=A.charAt(Q),aA.test(d)?Q++:(d=t,N===0&&G(qE)),d!==t)for(;d!==t;)C.push(d),d=A.charAt(Q),aA.test(d)?Q++:(d=t,N===0&&G(qE));else C=t;return C!==t&&(gA=E,C=Ry(C)),E=C,E}function RA(){var E,C;for(N++,E=[],C=rl(),C===t&&(C=sl(),C===t&&(C=ol(),C===t&&(C=nl())));C!==t;)E.push(C),C=rl(),C===t&&(C=sl(),C===t&&(C=ol(),C===t&&(C=nl())));return N--,C=t,N===0&&G($p),E}function rl(){var E,C;if(E=[],C=A.charAt(Q),qA.test(C)?Q++:(C=t,N===0&&G(VE)),C!==t)for(;C!==t;)E.push(C),C=A.charAt(Q),qA.test(C)?Q++:(C=t,N===0&&G(VE));else E=t;return E}function sl(){var E,C,d,I,F;if(E=Q,A.substr(Q,2)===M?(C=M,Q+=2):(C=t,N===0&&G(Ay)),C!==t){for(d=[],I=A.charAt(Q),TA.test(I)?Q++:(I=t,N===0&&G(mo));I!==t;)d.push(I),I=A.charAt(Q),TA.test(I)?Q++:(I=t,N===0&&G(mo));A.charCodeAt(Q)===10?(I=W,Q++):(I=t,N===0&&G(WE)),I===t&&(A.substr(Q,2)===eA?(I=eA,Q+=2):(I=t,N===0&&G(jE)),I===t&&(A.charCodeAt(Q)===13?(I=tA,Q++):(I=t,N===0&&G(XE)),I===t&&(I=Q,N++,A.length>Q?(F=A.charAt(Q),Q++):(F=t,N===0&&G(wo)),N--,F===t?I=void 0:(Q=I,I=t)))),I!==t?(C=[C,d,I],E=C):(Q=E,E=t)}else Q=E,E=t;return E}function ol(){var E,C,d,I,F;if(E=Q,A.charCodeAt(Q)===35?(C=oA,Q++):(C=t,N===0&&G(ey)),C!==t){for(d=[],I=A.charAt(Q),TA.test(I)?Q++:(I=t,N===0&&G(mo));I!==t;)d.push(I),I=A.charAt(Q),TA.test(I)?Q++:(I=t,N===0&&G(mo));A.charCodeAt(Q)===10?(I=W,Q++):(I=t,N===0&&G(WE)),I===t&&(A.substr(Q,2)===eA?(I=eA,Q+=2):(I=t,N===0&&G(jE)),I===t&&(A.charCodeAt(Q)===13?(I=tA,Q++):(I=t,N===0&&G(XE)),I===t&&(I=Q,N++,A.length>Q?(F=A.charAt(Q),Q++):(F=t,N===0&&G(wo)),N--,F===t?I=void 0:(Q=I,I=t)))),I!==t?(C=[C,d,I],E=C):(Q=E,E=t)}else Q=E,E=t;return E}function nl(){var E,C,d,I,F,b;if(E=Q,A.substr(Q,2)===x?(C=x,Q+=2):(C=t,N===0&&G(ty)),C!==t){for(d=[],I=Q,F=Q,N++,A.substr(Q,2)===J?(b=J,Q+=2):(b=t,N===0&&G(Gi)),N--,b===t?F=void 0:(Q=F,F=t),F!==t?(A.length>Q?(b=A.charAt(Q),Q++):(b=t,N===0&&G(wo)),b!==t?(F=[F,b],I=F):(Q=I,I=t)):(Q=I,I=t);I!==t;)d.push(I),I=Q,F=Q,N++,A.substr(Q,2)===J?(b=J,Q+=2):(b=t,N===0&&G(Gi)),N--,b===t?F=void 0:(Q=F,F=t),F!==t?(A.length>Q?(b=A.charAt(Q),Q++):(b=t,N===0&&G(wo)),b!==t?(F=[F,b],I=F):(Q=I,I=t)):(Q=I,I=t);A.substr(Q,2)===J?(I=J,Q+=2):(I=t,N===0&&G(Gi)),I!==t?(C=[C,d,I],E=C):(Q=E,E=t)}else Q=E,E=t;return E}if(ds=o(),e.peg$library)return{peg$result:ds,peg$currPos:Q,peg$FAILED:t,peg$maxFailExpected:Ro,peg$maxFailPos:Pe};if(ds!==t&&Q===A.length)return ds;throw ds!==t&&Q{let A=Bs.context.eventName,e=process.env.BASE_SHA||Bs.context.payload?.pull_request?.base?.sha||Bs.context.sha,t=process.env.HEAD_SHA||Bs.context.payload?.pull_request?.head?.sha||Bs.context.sha,r=[],s;A==="pull_request"||A==="workflow_dispatch"?s=`git diff --name-status ${e} ${t}`:s="git diff --name-status HEAD~1 HEAD";let o=(0,hp.execSync)(s,{encoding:"utf-8",maxBuffer:52428800}).trim();return o&&(r=o.split(` `).filter(Boolean).map(n=>{let[i,...a]=n.split(" "),c=a.join(" "),g=Fi(i);return{file:c,status:g}})),r};var Jp=Ct(HE());function Hp(A,e){let t=new Map;function r(c){let g=new Set,l=[];for(let u of c)g.has(u.file)||(g.add(u.file),l.push(u));return l}function s(c,g){return r([...c,...g])}function o(c,g){if(t.has(c))return t.get(c);let l=A.find(h=>h.key.name===c);if(!l)throw new Error(`Referenced statement key '${c}' does not exist.`);let u=n(l.value,g);return t.set(c,u),u}function n(c,g){switch(c.type){case"EXPRESSION_WITH_EXCEPT":{let l=n(c.base,g),u=[];for(let w of c.excludes){let R=n(w,g);u=s(u,R.matchedFiles)}let h=new Set(u.map(w=>w.file)),B=l.matchedFiles.filter(w=>!h.has(w.file));return{isTrue:l.isTrue&&B.length>0,matchedFiles:B}}case"OR":{let l=!1,u=[];for(let h of c.values){let B=n(h,g);B.isTrue&&(l=!0,u=s(u,B.matchedFiles))}return{isTrue:l,matchedFiles:l?u:[]}}case"AND":{if(c.values.length===0)return{isTrue:!0,matchedFiles:[]};let l=!0,u=[];for(let h of c.values){let B=n(h,g);if(!B.isTrue){l=!1;break}u=s(u,B.matchedFiles)}return{isTrue:l,matchedFiles:l?u:[]}}case"QUOTE_LITERAL":{let l=(0,Jp.default)(c.value,{dot:!0,nocase:!!c.ignoreCase}),u=g.filter(h=>l(h.file));if(c.suffix){let h=Fi(c.suffix);u=u.filter(B=>B.status===h)}return{isTrue:u.length>0,matchedFiles:u}}case"REGEX_LITERAL":{let l=new RegExp(c.pattern,c.flags),u=g.filter(h=>l.test(h.file));if(c.suffix){let h=Fi(c.suffix);u=u.filter(B=>B.status===h)}return{isTrue:u.length>0,matchedFiles:u}}case"NEGATE":{let l=n(c.exp,g);return{isTrue:!l.isTrue,matchedFiles:l.isTrue?[]:[]}}case"STATEMENT_REF":return o(c.value,g);default:throw new Error(`Unsupported node type: ${c.type}`)}}let i={},a={};for(let c of A)if(c.type==="STATEMENT"){let{isTrue:g,matchedFiles:l}=o(c.key.name,e);i[c.key.name]=g,c.key.path&&(a[c.key.name]=[...l].sort((u,h)=>u.file.localeCompare(h.file)))}return{changes:i,netFiles:a}}var OE=require("child_process"),Op=Ct(HE()),Pp=Ct(require("crypto"));function qp(){return(0,OE.execSync)("git ls-files",{encoding:"utf-8",maxBuffer:52428800}).split(` `).filter(Boolean)}async function Vp(A,e){let t=new Map;function r(a){return Array.from(new Set(a))}function s(a,c){return r([...a,...c])}function o(a,c){if(t.has(a))return t.get(a);let g=A.find(u=>u.key.name===a);if(!g)throw new Error(`Referenced statement key '${a}' does not exist.`);let l=n(g.value,c);return t.set(a,l),l}function n(a,c){switch(a.type){case"EXPRESSION_WITH_EXCEPT":{let g=n(a.base,c),l=[];for(let B of a.excludes){let w=n(B,c);l=s(l,w.matchedFiles)}let u=new Set(l);return{matchedFiles:g.matchedFiles.filter(B=>!u.has(B)),excludedFiles:[]}}case"OR":{if(a.values.length===0)return{matchedFiles:[],excludedFiles:[]};let g=[];for(let l of a.values){let u=n(l,c);g=s(g,u.matchedFiles)}return{matchedFiles:g,excludedFiles:[]}}case"AND":{if(a.values.length===0)return{matchedFiles:[],excludedFiles:[]};let g=null;for(let l of a.values){let u=n(l,c);if(u.matchedFiles.length===0)return{matchedFiles:[],excludedFiles:[]};if(g===null)g=u.matchedFiles;else{let h=new Set(u.matchedFiles);g=g.filter(B=>h.has(B))}if(g.length===0)return{matchedFiles:[],excludedFiles:[]}}return{matchedFiles:g||[],excludedFiles:[]}}case"QUOTE_LITERAL":{let g=(0,Op.default)(a.value,{dot:!0});return{matchedFiles:c.filter(u=>g(u)),excludedFiles:[]}}case"NEGATE":{let g=n(a.exp,c),l=s(g.matchedFiles,g.excludedFiles),u=new Set(l);return{matchedFiles:c.filter(B=>!u.has(B)),excludedFiles:l}}case"STATEMENT_REF":return o(a.value,c);default:throw new Error(`Unsupported node type: ${a.type}`)}}let i={};for(let a of A)if(a.type==="STATEMENT"){let{matchedFiles:c,excludedFiles:g}=o(a.key.name,e);if(a.key.path){let l=new Set(g),h=c.filter(w=>!l.has(w)).slice().sort(),B=Pp.default.createHash("sha1");for(let w of h){let R=(0,OE.execSync)(`git hash-object "${w}"`,{encoding:"utf-8"}).trim();B.update(R+` -`)}i[a.key.path]=B.digest("hex")}}return i}var Wp=(A,e,t,r,s)=>{let o=process.env.BASE_REF||yo.context.payload?.pull_request?.base?.ref||process.env.GITHUB_REF_NAME,n=`${A}:${o}-${t}`;e||r&&(n=`${A}:${r}-${t}`);let i=`${A}:latest`;return yo.context.eventName==="pull_request"&&(i=`${A}:pr-${yo.context.payload.pull_request.number}`),[n,i].map(a=>`${s||""}${a}`)},po=(A,e)=>{e&&le.info(A)};async function jp(){try{let A={},e={},t={},r=le.getInput("rules",{required:!0}),s=le.getInput("verbose",{required:!1})==="true",o=le.getInput("gitflow-production-branch",{required:!1})||"",n=le.getInput("recommended-imagetags-prefix",{required:!1})||"";if(po(`github.context: ${JSON.stringify(yo.context,void 0,2)}`,s),r){let a=Bp(r,void 0);if(!Array.isArray(a))throw new Error("Rules must be an array of statements");let c=await Ip();po(`Changed Files: ${c.join(` +`)}i[a.key.path]=B.digest("hex")}}return i}var Wp=(A,e,t,r,s)=>{let o=process.env.BASE_REF||yo.context.payload?.pull_request?.base?.ref||process.env.GITHUB_REF_NAME;o&&o.includes("/")&&(o=o.split("/").pop());let n=`${A}:${o}-${t}`;e||r&&(n=`${A}:${r}-${t}`);let i=`${A}:latest`;return yo.context.eventName==="pull_request"&&(i=`${A}:pr-${yo.context.payload.pull_request.number}`),[n,i].map(a=>`${s||""}${a}`)},po=(A,e)=>{e&&le.info(A)};async function jp(){try{let A={},e={},t={},r=le.getInput("rules",{required:!0}),s=le.getInput("verbose",{required:!1})==="true",o=le.getInput("gitflow-production-branch",{required:!1})||"",n=le.getInput("recommended-imagetags-prefix",{required:!1})||"";if(po(`github.context: ${JSON.stringify(yo.context,void 0,2)}`,s),r){let a=Bp(r,void 0);if(!Array.isArray(a))throw new Error("Rules must be an array of statements");let c=await Ip();po(`Changed Files: ${c.join(` `)}`,s);let{changes:g}=Hp(a,c);for(let[h,B]of Object.entries(g))t[h]=B;let l=await qp();po(`All Git Files: ${l.join(` `)}`,s);let u=await Vp(a,l);for(let h of a){if(h.type!=="STATEMENT")continue;let{key:B}=h;if(B.path){e[B.name]=u[B.name];let w=Wp(B.name,t[B.name],u[B.name],o,n);A[B.name]=w,po(`Key: ${B.name}, Path: ${B.path}, Commit SHA: ${u}, Image: ${w}`,s)}}}let i={shas:e,changes:t,recommended_imagetags:A};le.setOutput("affected",i),le.setOutput("affected_shas",e),le.setOutput("affected_changes",t),le.setOutput("affected_recommended_imagetags",A),le.info(`affected: ${JSON.stringify(i,null,2)}!`)}catch(A){throw le.setFailed(A.message),A}}process.env.JEST_WORKER_ID||jp();0&&(module.exports={getImageName,log,run});