From 60afb066b9890d18f04ac7ba8569725c1f880838 Mon Sep 17 00:00:00 2001 From: kylegalbraith Date: Mon, 10 Jul 2023 12:42:05 +0200 Subject: [PATCH] build new action with buildx fallback --- dist/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index a9f2df3..dd7214b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -38,7 +38,7 @@ Expecting `+ge.join(", ")+", got '"+(this.terminals_[O]||O)+"'":n1="Parse error ${e}`,D9=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),k9=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),C9=(t,e,r)=>{let a=r===""?"":`with ${r.trim()}() `,i=N9.bind(null,a,e.toString());Object.defineProperty(i,"name",k9),Object.defineProperty(t,"toString",{...D9,value:i})};function Wi(t,e,{ignoreNonConfigurable:r=!1}={}){let{name:a}=t;for(let i of Reflect.ownKeys(e))P9(t,e,i,r);return A9(t,e),C9(t,e,a),t}var Ar=new WeakMap,h2=(t,e={})=>{if(typeof t!="function")throw new TypeError("Expected a function");let r,a=0,i=t.displayName||t.name||"",p=function(...s){if(Ar.set(p,++a),a===1)r=t.apply(this,s),t=null;else if(e.throw===!0)throw new Error(`Function \`${i}\` can only be called once`);return r};return Wi(p,t),Ar.set(p,a),p};h2.callCount=t=>{if(!Ar.has(t))throw new Error(`The given function \`${t.name}\` is not wrapped by the \`onetime\` package`);return Ar.get(t)};var g2=h2;var y2=require("node:os");var v2=()=>{let t=w2-_2+1;return Array.from({length:t},R9)},R9=(t,e)=>({name:`SIGRT${e+1}`,number:_2+e,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),_2=34,w2=64;var E2=require("node:os");var b2=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];var zi=()=>{let t=v2();return[...b2,...t].map(x9)},x9=({name:t,number:e,description:r,action:a,forced:i=!1,standard:p})=>{let{signals:{[t]:s}}=E2.constants,n=s!==void 0;return{name:t,number:n?s:e,description:r,supported:n,action:a,forced:i,standard:p}};var G9=()=>{let t=zi();return Object.fromEntries(t.map(I9))},I9=({name:t,number:e,description:r,supported:a,action:i,forced:p,standard:s})=>[t,{name:t,number:e,description:r,supported:a,action:i,forced:p,standard:s}],T2=G9(),L9=()=>{let t=zi(),e=64+1,r=Array.from({length:e},(a,i)=>V9(i,t));return Object.assign({},...r)},V9=(t,e)=>{let r=F9(t,e);if(r===void 0)return{};let{name:a,description:i,supported:p,action:s,forced:n,standard:o}=r;return{[t]:{name:a,number:t,description:i,supported:p,action:s,forced:n,standard:o}}},F9=(t,e)=>{let r=e.find(({name:a})=>y2.constants.signals[a]===t);return r!==void 0?r:e.find(a=>a.number===t)},Bh=L9();var U9=({timedOut:t,timeout:e,errorCode:r,signal:a,signalDescription:i,exitCode:p,isCanceled:s})=>t?`timed out after ${e} milliseconds`:s?"was canceled":r!==void 0?`failed with ${r}`:a!==void 0?`was killed with ${a} (${i})`:p!==void 0?`failed with exit code ${p}`:"failed",k1=({stdout:t,stderr:e,all:r,error:a,signal:i,exitCode:p,command:s,escapedCommand:n,timedOut:o,isCanceled:d,killed:u,parsed:{options:{timeout:l}}})=>{p=p===null?void 0:p,i=i===null?void 0:i;let m=i===void 0?void 0:T2[i].description,f=a&&a.code,g=`Command ${U9({timedOut:o,timeout:l,errorCode:f,signal:i,signalDescription:m,exitCode:p,isCanceled:d})}: ${s}`,P=Object.prototype.toString.call(a)==="[object Error]",T=P?`${g} ${a.message}`:g,E=[T,e,t].filter(Boolean).join(` `);return P?(a.originalMessage=a.message,a.message=E):a=new Error(E),a.shortMessage=T,a.command=s,a.escapedCommand=n,a.exitCode=p,a.signal=i,a.signalDescription=m,a.stdout=t,a.stderr=e,r!==void 0&&(a.all=r),"bufferedData"in a&&delete a.bufferedData,a.failed=!0,a.timedOut=!!o,a.isCanceled=d,a.killed=u&&!o,a};var Nr=["stdin","stdout","stderr"],B9=t=>Nr.some(e=>t[e]!==void 0),S2=t=>{if(!t)return;let{stdio:e}=t;if(e===void 0)return Nr.map(a=>t[a]);if(B9(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Nr.map(a=>`\`${a}\``).join(", ")}`);if(typeof e=="string")return e;if(!Array.isArray(e))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);let r=Math.max(e.length,Nr.length);return Array.from({length:r},(a,i)=>e[i])};var C2=C(require("node:os"),1),R2=C(k2(),1),q9=1e3*5,x2=(t,e="SIGTERM",r={})=>{let a=t(e);return M9(t,e,r,a),a},M9=(t,e,r,a)=>{if(!j9(e,r,a))return;let i=W9(r),p=setTimeout(()=>{t("SIGKILL")},i);p.unref&&p.unref()},j9=(t,{forceKillAfterTimeout:e},r)=>H9(t)&&e!==!1&&r,H9=t=>t===C2.default.constants.signals.SIGTERM||typeof t=="string"&&t.toUpperCase()==="SIGTERM",W9=({forceKillAfterTimeout:t=!0})=>{if(t===!0)return q9;if(!Number.isFinite(t)||t<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`);return t},G2=(t,e)=>{t.kill()&&(e.isCanceled=!0)},z9=(t,e,r)=>{t.kill(e),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:e}))},I2=(t,{timeout:e,killSignal:r="SIGTERM"},a)=>{if(e===0||e===void 0)return a;let i,p=new Promise((n,o)=>{i=setTimeout(()=>{z9(t,r,o)},e)}),s=a.finally(()=>{clearTimeout(i)});return Promise.race([p,s])},L2=({timeout:t})=>{if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`)},V2=async(t,{cleanup:e,detached:r},a)=>{if(!e||r)return a;let i=(0,R2.default)(()=>{t.kill()});return a.finally(()=>{i()})};var F2=require("node:fs"),U2=require("node:child_process");function xr(t){return t!==null&&typeof t=="object"&&typeof t.pipe=="function"}function Ji(t){return xr(t)&&t.writable!==!1&&typeof t._write=="function"&&typeof t._writableState=="object"}var $9=t=>t instanceof U2.ChildProcess&&typeof t.then=="function",Qi=(t,e,r)=>{if(typeof r=="string")return t[e].pipe((0,F2.createWriteStream)(r)),t;if(Ji(r))return t[e].pipe(r),t;if(!$9(r))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!Ji(r.stdin))throw new TypeError("The target child process's stdin must be available.");return t[e].pipe(r.stdin),r},B2=t=>{t.stdout!==null&&(t.pipeStdout=Qi.bind(void 0,t,"stdout")),t.stderr!==null&&(t.pipeStderr=Qi.bind(void 0,t,"stderr")),t.all!==void 0&&(t.pipeAll=Qi.bind(void 0,t,"all"))};var Ir=require("node:fs");var ep=C(j2(),1),z2=C(W2(),1),$2=t=>{if(t!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},t8=({input:t,inputFile:e})=>typeof e!="string"?t:($2(t),(0,Ir.readFileSync)(e)),K2=t=>{let e=t8(t);if(xr(e))throw new TypeError("The `input` option cannot be a stream in sync mode");return e},r8=({input:t,inputFile:e})=>typeof e!="string"?t:($2(t),(0,Ir.createReadStream)(e)),J2=(t,e)=>{let r=r8(e);r!==void 0&&(xr(r)?r.pipe(t.stdin):t.stdin.end(r))},Q2=(t,{all:e})=>{if(!e||!t.stdout&&!t.stderr)return;let r=(0,z2.default)();return t.stdout&&r.add(t.stdout),t.stderr&&r.add(t.stderr),r},Xi=async(t,e)=>{if(!(!t||e===void 0)){t.destroy();try{return await e}catch(r){return r.bufferedData}}},Zi=(t,{encoding:e,buffer:r,maxBuffer:a})=>{if(!(!t||!r))return e?(0,ep.default)(t,{encoding:e,maxBuffer:a}):ep.default.buffer(t,{maxBuffer:a})},Y2=async({stdout:t,stderr:e,all:r},{encoding:a,buffer:i,maxBuffer:p},s)=>{let n=Zi(t,{encoding:a,buffer:i,maxBuffer:p}),o=Zi(e,{encoding:a,buffer:i,maxBuffer:p}),d=Zi(r,{encoding:a,buffer:i,maxBuffer:p*2});try{return await Promise.all([s,n,o,d])}catch(u){return Promise.all([{error:u,signal:u.signal,timedOut:u.timedOut},Xi(t,n),Xi(e,o),Xi(r,d)])}};var a8=(async()=>{})().constructor.prototype,i8=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(a8,t)]),tp=(t,e)=>{for(let[r,a]of i8){let i=typeof e=="function"?(...p)=>Reflect.apply(a.value,e(),p):a.value.bind(e);Reflect.defineProperty(t,r,{...a,value:i})}},X2=t=>new Promise((e,r)=>{t.on("exit",(a,i)=>{e({exitCode:a,signal:i})}),t.on("error",a=>{r(a)}),t.stdin&&t.stdin.on("error",a=>{r(a)})});var tl=require("node:buffer"),rl=require("node:child_process"),al=(t,e=[])=>Array.isArray(e)?[t,...e]:[t],p8=/^[\w.-]+$/,s8=/"/g,n8=t=>typeof t!="string"||p8.test(t)?t:`"${t.replace(s8,'\\"')}"`,rp=(t,e)=>al(t,e).join(" "),ap=(t,e)=>al(t,e).map(r=>n8(r)).join(" "),o8=/ +/g;var Z2=t=>{let e=typeof t;if(e==="string")return t;if(e==="number")return String(t);if(e==="object"&&t!==null&&!(t instanceof rl.ChildProcess)&&"stdout"in t){let r=typeof t.stdout;if(r==="string")return t.stdout;if(tl.Buffer.isBuffer(t.stdout))return t.stdout.toString();throw new TypeError(`Unexpected "${r}" stdout in template expression`)}throw new TypeError(`Unexpected "${e}" in template expression`)},el=(t,e,r)=>r||t.length===0||e.length===0?[...t,...e]:[...t.slice(0,-1),`${t[t.length-1]}${e[0]}`,...e.slice(1)],d8=({templates:t,expressions:e,tokens:r,index:a,template:i})=>{let p=i??t.raw[a],s=p.split(o8).filter(Boolean),n=el(r,s,p.startsWith(" "));if(a===e.length)return n;let o=e[a],d=Array.isArray(o)?o.map(u=>Z2(u)):[Z2(o)];return el(n,d,p.endsWith(" "))},ip=(t,e)=>{let r=[];for(let[a,i]of t.entries())r=d8({templates:t,expressions:e,tokens:r,index:a,template:i});return r};var il=require("node:util"),pl=C(require("node:process"),1),sl=(0,il.debuglog)("execa").enabled,Lr=(t,e)=>String(t).padStart(e,"0"),l8=()=>{let t=new Date;return`${Lr(t.getHours(),2)}:${Lr(t.getMinutes(),2)}:${Lr(t.getSeconds(),2)}.${Lr(t.getMilliseconds(),3)}`},pp=(t,{verbose:e})=>{e&&pl.default.stderr.write(`[${l8()}] ${t} -`)};var u8=1e3*1e3*100,m8=({env:t,extendEnv:e,preferLocal:r,localDir:a,execPath:i})=>{let p=e?{...x1.default.env,...t}:t;return r?f2({env:p,cwd:a,execPath:i}):p},ul=(t,e,r={})=>{let a=ll.default._parse(t,e,r);return t=a.command,e=a.args,r=a.options,r={maxBuffer:u8,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||x1.default.cwd(),execPath:x1.default.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:sl,...r},r.env=m8(r),r.stdio=S2(r),x1.default.platform==="win32"&&dl.default.basename(t,".exe")==="cmd"&&e.unshift("/q"),{file:t,args:e,options:r,parsed:a}},G1=(t,e,r)=>typeof e!="string"&&!ol.Buffer.isBuffer(e)?r===void 0?void 0:"":t.stripFinalNewline?Hi(e):e;function sp(t,e,r){let a=ul(t,e,r),i=rp(t,e),p=ap(t,e);pp(p,a.options),L2(a.options);let s;try{s=Vr.default.spawn(a.file,a.args,a.options)}catch(f){let h=new Vr.default.ChildProcess,g=Promise.reject(k1({error:f,stdout:"",stderr:"",all:"",command:i,escapedCommand:p,parsed:a,timedOut:!1,isCanceled:!1,killed:!1}));return tp(h,g),h}let n=X2(s),o=I2(s,a.options,n),d=V2(s,a.options,o),u={isCanceled:!1};s.kill=x2.bind(null,s.kill.bind(s)),s.cancel=G2.bind(null,s,u);let m=g2(async()=>{let[{error:f,exitCode:h,signal:g,timedOut:P},T,E,S]=await Y2(s,a.options,d),O=G1(a.options,T),K=G1(a.options,E),J=G1(a.options,S);if(f||h!==0||g!==null){let V=k1({error:f,exitCode:h,signal:g,stdout:O,stderr:K,all:J,command:i,escapedCommand:p,parsed:a,timedOut:P,isCanceled:u.isCanceled||(a.options.signal?a.options.signal.aborted:!1),killed:s.killed});if(!a.options.reject)return V;throw V}return{command:i,escapedCommand:p,exitCode:0,stdout:O,stderr:K,all:J,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return J2(s,a.options),s.all=Q2(s,a.options),B2(s),tp(s,m),s}function c8(t,e,r){let a=ul(t,e,r),i=rp(t,e),p=ap(t,e);pp(p,a.options);let s=K2(a.options),n;try{n=Vr.default.spawnSync(a.file,a.args,{...a.options,input:s})}catch(u){throw k1({error:u,stdout:"",stderr:"",all:"",command:i,escapedCommand:p,parsed:a,timedOut:!1,isCanceled:!1,killed:!1})}let o=G1(a.options,n.stdout,n.error),d=G1(a.options,n.stderr,n.error);if(n.error||n.status!==0||n.signal!==null){let u=k1({stdout:o,stderr:d,error:n.error,signal:n.signal,exitCode:n.status,command:i,escapedCommand:p,parsed:a,timedOut:n.error&&n.error.code==="ETIMEDOUT",isCanceled:!1,killed:n.signal!==null});if(!a.options.reject)return u;throw u}return{command:i,escapedCommand:p,exitCode:0,stdout:o,stderr:d,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}}var f8=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},nl=(t={})=>({preferLocal:!0,...f8(t),...t});function ml(t){function e(r,...a){if(!Array.isArray(r))return ml({...t,...r});let[i,...p]=ip(r,a);return sp(i,p,nl(t))}return e.sync=(r,...a)=>{if(!Array.isArray(r))throw new TypeError("Please use $(options).sync`command` instead of $.sync(options)`command`.");let[i,...p]=ip(r,a);return c8(i,p,nl(t))},e}var _g=ml();var Me=C(require("fs")),o4=C(a4()),Ye=C(require("path"));var s7=new s4.HttpClient("depot-build-push-action");async function d4(){try{let{exitCode:t}=await ba.getExecOutput("depot",[],{ignoreReturnCode:!0,silent:!0});return t===0}catch{return!1}}async function l4(){await ba.exec("depot",["version"],{failOnStdErr:!1})}async function i4(t,e,r){var s,n;let a=await n4.which(t,!0);console.log(`[command]${a} ${e.join(" ")}`);let i=sp(a,e,{...r,reject:!1,stdin:"inherit",stdout:"pipe",stderr:"pipe"});i.pipeStdout&&i.pipeStdout(process.stdout),i.pipeStderr&&i.pipeStderr(process.stdout);function p(o){i.kill(o)}process.on("SIGINT",p),process.on("SIGTERM",p);try{let o=await i;if(o.stderr.length>0&&o.exitCode!=0)throw new Error(`failed with: ${((n=(s=o.stderr.match(/(.*)\s*$/))==null?void 0:s[0])==null?void 0:n.trim())??"unknown error"}`)}finally{process.off("SIGINT",p),process.off("SIGTERM",p)}}async function u4(t){var n;let e=Ni(),r=o4.compile(t.context)({defaultContext:e}),a=[...k("--add-host",t.addHosts),...k("--allow",t.allow.join(",")),...k("--attest",t.attests),...k("--build-arg",t.buildArgs),...k("--build-context",t.buildContexts),...k("--cache-from",t.cacheFrom),...k("--cache-to",t.cacheTo),...k("--cgroup-parent",t.cgroupParent),...k("--file",t.file),...k("--iidfile",n7(t.outputs)?!1:m4()),...k("--label",t.labels),...k("--load",t.load),...k("--metadata-file",f4()),...k("--network",t.network),...k("--no-cache",t.noCache),...k("--no-cache-filter",t.noCacheFilters),...k("--output",t.outputs),...k("--platform",t.platforms.join(",")),...k("--pull",t.pull),...k("--push",t.push),...k("--sbom",t.sbom),...k("--shm-size",t.shmSize),...k("--ssh",t.ssh),...k("--tag",t.tags),...k("--target",t.target),...k("--ulimit",t.ulimit),...k("--secret",t.secrets.map(o=>Xp(o)).filter(o=>!!o)),...k("--secret",t.secretFiles.map(o=>Xp(o,!0)).filter(o=>!!o)),...k("--secret",t.githubToken&&!o7(t.secrets)&&r.startsWith(e)?Xp(`GIT_AUTH_TOKEN=${t.githubToken}`):!1)];t.provenance?a.push(...k("--provenance",t.provenance)):d7(t)||(((n=p4.context.payload.repository)==null?void 0:n.private)??!1?a.push("--provenance",Er("mode=min,inline-only=true")):a.push("--provenance",Er("mode=max")));let i=[...k("--project",t.project),...k("--build-platform",t.buildPlatform),...k("--lint",t.lint),...k("--lint-fail-on",t.lintFailOn)],p=[...a,...i],s=t.token??process.env.DEPOT_TOKEN;if(!s)try{let o=await ct.getIDToken("https://depot.dev"),d=await s7.postJson("https://github.depot.dev/auth/oidc/github-actions",{token:o});d.result&&d.result.token&&(s=d.result.token,ct.info("Exchanged GitHub Actions OIDC token for temporary Depot token"))}catch(o){ct.info(`Unable to exchange GitHub OIDC token for temporary Depot token: ${o}`)}try{await i4("depot",["build",...p,r],{env:{...process.env,...s?{DEPOT_TOKEN:s}:{}}})}catch(o){let d=t.lint&&o.message.includes("linting failed");if(t.buildxFallback&&!d)ct.warning(`falling back to buildx: ${o}`),await i4("docker",["buildx","build",...a,r]);else throw o}}function k(t,e){return e?e===!0?[t]:Array.isArray(e)?e.flatMap(r=>[t,r]):[t,e]:[]}function n7(t){let e=O1(t.join(` +`)};var u8=1e3*1e3*100,m8=({env:t,extendEnv:e,preferLocal:r,localDir:a,execPath:i})=>{let p=e?{...x1.default.env,...t}:t;return r?f2({env:p,cwd:a,execPath:i}):p},ul=(t,e,r={})=>{let a=ll.default._parse(t,e,r);return t=a.command,e=a.args,r=a.options,r={maxBuffer:u8,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||x1.default.cwd(),execPath:x1.default.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:sl,...r},r.env=m8(r),r.stdio=S2(r),x1.default.platform==="win32"&&dl.default.basename(t,".exe")==="cmd"&&e.unshift("/q"),{file:t,args:e,options:r,parsed:a}},G1=(t,e,r)=>typeof e!="string"&&!ol.Buffer.isBuffer(e)?r===void 0?void 0:"":t.stripFinalNewline?Hi(e):e;function sp(t,e,r){let a=ul(t,e,r),i=rp(t,e),p=ap(t,e);pp(p,a.options),L2(a.options);let s;try{s=Vr.default.spawn(a.file,a.args,a.options)}catch(f){let h=new Vr.default.ChildProcess,g=Promise.reject(k1({error:f,stdout:"",stderr:"",all:"",command:i,escapedCommand:p,parsed:a,timedOut:!1,isCanceled:!1,killed:!1}));return tp(h,g),h}let n=X2(s),o=I2(s,a.options,n),d=V2(s,a.options,o),u={isCanceled:!1};s.kill=x2.bind(null,s.kill.bind(s)),s.cancel=G2.bind(null,s,u);let m=g2(async()=>{let[{error:f,exitCode:h,signal:g,timedOut:P},T,E,S]=await Y2(s,a.options,d),O=G1(a.options,T),K=G1(a.options,E),J=G1(a.options,S);if(f||h!==0||g!==null){let V=k1({error:f,exitCode:h,signal:g,stdout:O,stderr:K,all:J,command:i,escapedCommand:p,parsed:a,timedOut:P,isCanceled:u.isCanceled||(a.options.signal?a.options.signal.aborted:!1),killed:s.killed});if(!a.options.reject)return V;throw V}return{command:i,escapedCommand:p,exitCode:0,stdout:O,stderr:K,all:J,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return J2(s,a.options),s.all=Q2(s,a.options),B2(s),tp(s,m),s}function c8(t,e,r){let a=ul(t,e,r),i=rp(t,e),p=ap(t,e);pp(p,a.options);let s=K2(a.options),n;try{n=Vr.default.spawnSync(a.file,a.args,{...a.options,input:s})}catch(u){throw k1({error:u,stdout:"",stderr:"",all:"",command:i,escapedCommand:p,parsed:a,timedOut:!1,isCanceled:!1,killed:!1})}let o=G1(a.options,n.stdout,n.error),d=G1(a.options,n.stderr,n.error);if(n.error||n.status!==0||n.signal!==null){let u=k1({stdout:o,stderr:d,error:n.error,signal:n.signal,exitCode:n.status,command:i,escapedCommand:p,parsed:a,timedOut:n.error&&n.error.code==="ETIMEDOUT",isCanceled:!1,killed:n.signal!==null});if(!a.options.reject)return u;throw u}return{command:i,escapedCommand:p,exitCode:0,stdout:o,stderr:d,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}}var f8=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},nl=(t={})=>({preferLocal:!0,...f8(t),...t});function ml(t){function e(r,...a){if(!Array.isArray(r))return ml({...t,...r});let[i,...p]=ip(r,a);return sp(i,p,nl(t))}return e.sync=(r,...a)=>{if(!Array.isArray(r))throw new TypeError("Please use $(options).sync`command` instead of $.sync(options)`command`.");let[i,...p]=ip(r,a);return c8(i,p,nl(t))},e}var _g=ml();var Me=C(require("fs")),o4=C(a4()),Ye=C(require("path"));var s7=new s4.HttpClient("depot-build-push-action");async function d4(){try{let{exitCode:t}=await ba.getExecOutput("depot",[],{ignoreReturnCode:!0,silent:!0});return t===0}catch{return!1}}async function l4(){await ba.exec("depot",["version"],{failOnStdErr:!1})}async function i4(t,e,r){var s,n;let a=await n4.which(t,!0);console.log(`[command]${a} ${e.join(" ")}`);let i=sp(a,e,{...r,reject:!1,stdin:"inherit",stdout:"pipe",stderr:"pipe"});i.pipeStdout&&i.pipeStdout(process.stdout),i.pipeStderr&&i.pipeStderr(process.stdout);function p(o){i.kill(o)}process.on("SIGINT",p),process.on("SIGTERM",p);try{let o=await i;if(o.stderr.length>0&&o.exitCode!=0)throw new Error(`failed with: ${((n=(s=o.stderr.match(/(.*)\s*$/))==null?void 0:s[0])==null?void 0:n.trim())??"unknown error"}`)}finally{process.off("SIGINT",p),process.off("SIGTERM",p)}}async function u4(t){var n,o;let e=Ni(),r=o4.compile(t.context)({defaultContext:e}),a=[...k("--add-host",t.addHosts),...k("--allow",t.allow.join(",")),...k("--attest",t.attests),...k("--build-arg",t.buildArgs),...k("--build-context",t.buildContexts),...k("--cache-from",t.cacheFrom),...k("--cache-to",t.cacheTo),...k("--cgroup-parent",t.cgroupParent),...k("--file",t.file),...k("--iidfile",n7(t.outputs)?!1:m4()),...k("--label",t.labels),...k("--load",t.load),...k("--metadata-file",f4()),...k("--network",t.network),...k("--no-cache",t.noCache),...k("--no-cache-filter",t.noCacheFilters),...k("--output",t.outputs),...k("--platform",t.platforms.join(",")),...k("--pull",t.pull),...k("--push",t.push),...k("--sbom",t.sbom),...k("--shm-size",t.shmSize),...k("--ssh",t.ssh),...k("--tag",t.tags),...k("--target",t.target),...k("--ulimit",t.ulimit),...k("--secret",t.secrets.map(d=>Xp(d)).filter(d=>!!d)),...k("--secret",t.secretFiles.map(d=>Xp(d,!0)).filter(d=>!!d)),...k("--secret",t.githubToken&&!o7(t.secrets)&&r.startsWith(e)?Xp(`GIT_AUTH_TOKEN=${t.githubToken}`):!1)];t.provenance?a.push(...k("--provenance",t.provenance)):d7(t)||(((n=p4.context.payload.repository)==null?void 0:n.private)??!1?a.push("--provenance",Er("mode=min,inline-only=true")):a.push("--provenance",Er("mode=max")));let i=[...k("--project",t.project),...k("--build-platform",t.buildPlatform),...k("--lint",t.lint),...k("--lint-fail-on",t.lintFailOn)],p=[...a,...i],s=t.token??process.env.DEPOT_TOKEN;if(!s)try{let d=await ct.getIDToken("https://depot.dev"),u=await s7.postJson("https://github.depot.dev/auth/oidc/github-actions",{token:d});u.result&&u.result.token&&(s=u.result.token,ct.info("Exchanged GitHub Actions OIDC token for temporary Depot token"))}catch(d){ct.info(`Unable to exchange GitHub OIDC token for temporary Depot token: ${d}`)}try{await i4("depot",["build",...p,r],{env:{...process.env,...s?{DEPOT_TOKEN:s}:{}}})}catch(d){let u=t.lint&&((o=d.message)==null?void 0:o.includes("linting failed"));if(t.buildxFallback&&!u)ct.warning(`falling back to buildx: ${d}`),await i4("docker",["buildx","build",...a,r]);else throw d}}function k(t,e){return e?e===!0?[t]:Array.isArray(e)?e.flatMap(r=>[t,r]):[t,e]:[]}function n7(t){let e=O1(t.join(` `),{columns:!1,relaxColumnCount:!0,trim:!0});for(let r of e){if(r.length===1&&!r[0].startsWith("type="))return!0;for(let[a,i]of r.map(p=>p.split("=").map(s=>s.trim())))if(a==="type"&&(i==="local"||i==="tar"))return!0}return!1}function o7(t){return t.some(e=>e.startsWith("GIT_AUTH_TOKEN="))}function Xp(t,e){try{let r=t.indexOf("="),a=t.substring(0,r),i=t.substring(r+1);if(!a||!i)throw new Error(`Invalid secret: ${t}`);if(e){if(!Me.existsSync(i))throw new Error(`Secret file not found: ${i}`);i=Me.readFileSync(i,"utf8")}let p=pd();return Me.writeFileSync(p,i),`id=${a},src=${p}`}catch(r){ct.warning(r.message)}}function m4(){return Ye.join(jt(),"iidfile").split(Ye.sep).join(Ye.posix.sep)}function c4(){let t=m4();if(Me.existsSync(t))return Me.readFileSync(t,{encoding:"utf-8"}).trim()}function f4(){return Ye.join(jt(),"metadata-file").split(Ye.sep).join(Ye.posix.sep)}function h4(){let t=f4();if(!Me.existsSync(t))return;let e=Me.readFileSync(t,{encoding:"utf-8"}).trim();if(e!=="null")return e}function g4(t){return t===void 0?void 0:JSON.parse(t)["containerimage.digest"]}function d7(t){return t.load||t.outputs.some(e=>e.includes("type=docker"))}async function u7(){if(!await d4())return z.setFailed("Depot CLI is not installed. See https://github.com/depot/setup-action to install it before this step.");await z.group("Depot version",async()=>{await l4()});let t=ad();await u4(t);let e=c4(),r=h4(),a=g4(r);e&&await z.group("ImageID",async()=>{z.info(e),z.setOutput("imageid",e)}),a&&await z.group("Digest",async()=>{z.info(a),z.setOutput("digest",a)}),r&&await z.group("Metadata",async()=>{z.info(r),z.setOutput("metadata",r)})}async function m7(){let t=jt();t.length!==0&&(z.startGroup(`Removing temp folder ${t}`),v4.rmSync(t,{recursive:!0}),z.endGroup())}(Di?m7():u7()).catch(t=>{t instanceof Error?z.setFailed(t.message):z.setFailed(`${t}`)}); /*! Bundled license information: