diff --git a/__tests__/context.test.ts b/__tests__/context.test.ts index 5af3541..622474f 100644 --- a/__tests__/context.test.ts +++ b/__tests__/context.test.ts @@ -1,6 +1,17 @@ -import {expect, test} from 'vitest'; +import {afterEach, expect, test} from 'vitest'; +import * as path from 'path'; -import {getInputs} from '../src/context.js'; +import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx.js'; + +import {getAuthList, getInputs} from '../src/context.js'; + +afterEach(() => { + for (const key of Object.keys(process.env)) { + if (key.startsWith('INPUT_')) { + delete process.env[key]; + } + } +}); test('with password and username getInputs does not throw error', async () => { process.env['INPUT_USERNAME'] = 'dbowie'; @@ -10,3 +21,15 @@ test('with password and username getInputs does not throw error', async () => { getInputs(); }).not.toThrow(); }); + +test('getAuthList uses the default Docker Hub registry when computing scoped config dir', async () => { + process.env['INPUT_USERNAME'] = 'dbowie'; + process.env['INPUT_PASSWORD'] = 'groundcontrol'; + process.env['INPUT_SCOPE'] = 'myscope'; + process.env['INPUT_LOGOUT'] = 'false'; + const [auth] = getAuthList(getInputs()); + expect(auth).toMatchObject({ + registry: 'docker.io', + configDir: path.join(Buildx.configDir, 'config', 'registry-1.docker.io', 'myscope') + }); +}); diff --git a/__tests__/docker.test.ts b/__tests__/docker.test.ts index ba836ad..e4d65a7 100644 --- a/__tests__/docker.test.ts +++ b/__tests__/docker.test.ts @@ -1,15 +1,10 @@ import {expect, test, vi} from 'vitest'; -import * as path from 'path'; import {Docker} from '@docker/actions-toolkit/lib/docker/docker.js'; import {loginStandard, logout} from '../src/docker.js'; -process.env['RUNNER_TEMP'] = path.join(__dirname, 'runner'); - test('loginStandard calls exec', async () => { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore const execSpy = vi.spyOn(Docker, 'getExecOutput').mockImplementation(async () => { return { exitCode: expect.any(Number), @@ -38,8 +33,6 @@ test('loginStandard calls exec', async () => { }); test('logout calls exec', async () => { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore const execSpy = vi.spyOn(Docker, 'getExecOutput').mockImplementation(async () => { return { exitCode: expect.any(Number), diff --git a/dist/index.js b/dist/index.js index df63576..1d60159 100644 --- a/dist/index.js +++ b/dist/index.js @@ -14,5 +14,5 @@ function isNothing(e){return typeof e==="undefined"||e===null}function js_yaml_i /* v8 ignore next -- @preserve */ ()=>new ArrayBuffer(0)))}}function isJSONResponse(e){return e.type==="application/json"||e.type==="application/scim+json"}function toErrorMessage(e){if(typeof e==="string"){return e}if(e instanceof ArrayBuffer){return"Unknown error"}if("message"in e){const t="documentation_url"in e?` - ${e.documentation_url}`:"";return Array.isArray(e.errors)?`${e.message}: ${e.errors.map((e=>JSON.stringify(e))).join(", ")}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function dist_bundle_withDefaults(e,t){const n=e.defaults(t);const newApi=function(e,t){const o=n.merge(e,t);if(!o.request||!o.request.hook){return fetchWrapper(n.parse(o))}const request2=(e,t)=>fetchWrapper(n.parse(n.merge(e,t)));Object.assign(request2,{endpoint:n,defaults:dist_bundle_withDefaults.bind(null,n)});return o.request.hook(request2,o)};return Object.assign(newApi,{endpoint:n,defaults:dist_bundle_withDefaults.bind(null,n)})}var lh=dist_bundle_withDefaults(Yf,ch); /* v8 ignore next -- @preserve */ -/* v8 ignore else -- @preserve */var uh="0.0.0-development";function _buildMessageForResponseErrors(e){return`Request failed due to following response errors:\n`+e.errors.map((e=>` - ${e.message}`)).join("\n")}var dh=class extends Error{constructor(e,t,n){super(_buildMessageForResponseErrors(n));this.request=e;this.headers=t;this.response=n;this.errors=n.errors;this.data=n.data;if(Error.captureStackTrace){Error.captureStackTrace(this,this.constructor)}}name="GraphqlResponseError";errors;data};var ph=["method","baseUrl","url","headers","request","query","mediaType","operationName"];var Ah=["query","method","url"];var mh=/\/api\/v3\/?$/;function graphql(e,t,n){if(n){if(typeof t==="string"&&"query"in n){return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`))}for(const e in n){if(!Ah.includes(e))continue;return Promise.reject(new Error(`[@octokit/graphql] "${e}" cannot be used as variable name`))}}const o=typeof t==="string"?Object.assign({query:t},n):t;const i=Object.keys(o).reduce(((e,t)=>{if(ph.includes(t)){e[t]=o[t];return e}if(!e.variables){e.variables={}}e.variables[t]=o[t];return e}),{});const c=o.baseUrl||e.endpoint.DEFAULTS.baseUrl;if(mh.test(c)){i.url=c.replace(mh,"/api/graphql")}return e(i).then((e=>{if(e.data.errors){const t={};for(const n of Object.keys(e.headers)){t[n]=e.headers[n]}throw new dh(i,t,e.data)}return e.data.data}))}function graphql_dist_bundle_withDefaults(e,t){const n=e.defaults(t);const newApi=(e,t)=>graphql(n,e,t);return Object.assign(newApi,{defaults:graphql_dist_bundle_withDefaults.bind(null,n),endpoint:n.endpoint})}var gh=graphql_dist_bundle_withDefaults(lh,{headers:{"user-agent":`octokit-graphql.js/${uh} ${getUserAgent()}`},method:"POST",url:"/graphql"});function withCustomRequest(e){return graphql_dist_bundle_withDefaults(e,{method:"POST",url:"/graphql"})}var fh="(?:[a-zA-Z0-9_-]+)";var hh="\\.";var yh=new RegExp(`^${fh}${hh}${fh}${hh}${fh}$`);var Eh=yh.test.bind(yh);async function auth(e){const t=Eh(e);const n=e.startsWith("v1.")||e.startsWith("ghs_");const o=e.startsWith("ghu_");const i=t?"app":n?"installation":o?"user-to-server":"oauth";return{type:"token",token:e,tokenType:i}}function withAuthorizationPrefix(e){if(e.split(/\./).length===3){return`bearer ${e}`}return`token ${e}`}async function hook(e,t,n,o){const i=t.endpoint.merge(n,o);i.headers.authorization=withAuthorizationPrefix(e);return t(i)}var Ch=function createTokenAuth2(e){if(!e){throw new Error("[@octokit/auth-token] No token passed to createTokenAuth")}if(typeof e!=="string"){throw new Error("[@octokit/auth-token] Token passed to createTokenAuth is not a string")}e=e.replace(/^(token|bearer) +/i,"");return Object.assign(auth.bind(null,e),{hook:hook.bind(null,e)})};const Ih="7.0.6";const dist_src_noop=()=>{};const bh=console.warn.bind(console);const Sh=console.error.bind(console);function createLogger(e={}){if(typeof e.debug!=="function"){e.debug=dist_src_noop}if(typeof e.info!=="function"){e.info=dist_src_noop}if(typeof e.warn!=="function"){e.warn=bh}if(typeof e.error!=="function"){e.error=Sh}return e}const Bh=`octokit-core.js/${Ih} ${getUserAgent()}`;class Octokit{static VERSION=Ih;static defaults(e){const t=class extends(this){constructor(...t){const n=t[0]||{};if(typeof e==="function"){super(e(n));return}super(Object.assign({},e,n,n.userAgent&&e.userAgent?{userAgent:`${n.userAgent} ${e.userAgent}`}:null))}};return t}static plugins=[];static plugin(...e){const t=this.plugins;const n=class extends(this){static plugins=t.concat(e.filter((e=>!t.includes(e))))};return n}constructor(e={}){const t=new Gf.Collection;const n={baseUrl:lh.endpoint.DEFAULTS.baseUrl,headers:{},request:Object.assign({},e.request,{hook:t.bind(null,"request")}),mediaType:{previews:[],format:""}};n.headers["user-agent"]=e.userAgent?`${e.userAgent} ${Bh}`:Bh;if(e.baseUrl){n.baseUrl=e.baseUrl}if(e.previews){n.mediaType.previews=e.previews}if(e.timeZone){n.headers["time-zone"]=e.timeZone}this.request=lh.defaults(n);this.graphql=withCustomRequest(this.request).defaults(n);this.log=createLogger(e.log);this.hook=t;if(!e.authStrategy){if(!e.auth){this.auth=async()=>({type:"unauthenticated"})}else{const n=Ch(e.auth);t.wrap("request",n.hook);this.auth=n}}else{const{authStrategy:n,...o}=e;const i=n(Object.assign({request:this.request,log:this.log,octokit:this,octokitOptions:o},e.auth));t.wrap("request",i.hook);this.auth=i}const o=this.constructor;for(let t=0;t({async next(){if(!p)return{done:true};try{const e=await i({method:c,url:p,headers:d});const t=normalizePaginatedListResponse(e);p=((t.headers.link||"").match(/<([^<>]+)>;\s*rel="next"/)||[])[1];if(!p&&"total_commits"in t.data){const e=new URL(t.url);const n=e.searchParams;const o=parseInt(n.get("page")||"1",10);const i=parseInt(n.get("per_page")||"250",10);if(o*i{if(i.done){return t}let c=false;function done(){c=true}t=t.concat(o?o(i.value,done):i.value.data);if(c){return t}return gather(e,t,n,o)}))}var vh=Object.assign(paginate,{iterator:iterator});var Ph=null&&["GET /advisories","GET /app/hook/deliveries","GET /app/installation-requests","GET /app/installations","GET /assignments/{assignment_id}/accepted_assignments","GET /classrooms","GET /classrooms/{classroom_id}/assignments","GET /enterprises/{enterprise}/code-security/configurations","GET /enterprises/{enterprise}/code-security/configurations/{configuration_id}/repositories","GET /enterprises/{enterprise}/dependabot/alerts","GET /enterprises/{enterprise}/teams","GET /enterprises/{enterprise}/teams/{enterprise-team}/memberships","GET /enterprises/{enterprise}/teams/{enterprise-team}/organizations","GET /events","GET /gists","GET /gists/public","GET /gists/starred","GET /gists/{gist_id}/comments","GET /gists/{gist_id}/commits","GET /gists/{gist_id}/forks","GET /installation/repositories","GET /issues","GET /licenses","GET /marketplace_listing/plans","GET /marketplace_listing/plans/{plan_id}/accounts","GET /marketplace_listing/stubbed/plans","GET /marketplace_listing/stubbed/plans/{plan_id}/accounts","GET /networks/{owner}/{repo}/events","GET /notifications","GET /organizations","GET /organizations/{org}/dependabot/repository-access","GET /orgs/{org}/actions/cache/usage-by-repository","GET /orgs/{org}/actions/hosted-runners","GET /orgs/{org}/actions/permissions/repositories","GET /orgs/{org}/actions/permissions/self-hosted-runners/repositories","GET /orgs/{org}/actions/runner-groups","GET /orgs/{org}/actions/runner-groups/{runner_group_id}/hosted-runners","GET /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories","GET /orgs/{org}/actions/runner-groups/{runner_group_id}/runners","GET /orgs/{org}/actions/runners","GET /orgs/{org}/actions/secrets","GET /orgs/{org}/actions/secrets/{secret_name}/repositories","GET /orgs/{org}/actions/variables","GET /orgs/{org}/actions/variables/{name}/repositories","GET /orgs/{org}/attestations/repositories","GET /orgs/{org}/attestations/{subject_digest}","GET /orgs/{org}/blocks","GET /orgs/{org}/campaigns","GET /orgs/{org}/code-scanning/alerts","GET /orgs/{org}/code-security/configurations","GET /orgs/{org}/code-security/configurations/{configuration_id}/repositories","GET /orgs/{org}/codespaces","GET /orgs/{org}/codespaces/secrets","GET /orgs/{org}/codespaces/secrets/{secret_name}/repositories","GET /orgs/{org}/copilot/billing/seats","GET /orgs/{org}/copilot/metrics","GET /orgs/{org}/dependabot/alerts","GET /orgs/{org}/dependabot/secrets","GET /orgs/{org}/dependabot/secrets/{secret_name}/repositories","GET /orgs/{org}/events","GET /orgs/{org}/failed_invitations","GET /orgs/{org}/hooks","GET /orgs/{org}/hooks/{hook_id}/deliveries","GET /orgs/{org}/insights/api/route-stats/{actor_type}/{actor_id}","GET /orgs/{org}/insights/api/subject-stats","GET /orgs/{org}/insights/api/user-stats/{user_id}","GET /orgs/{org}/installations","GET /orgs/{org}/invitations","GET /orgs/{org}/invitations/{invitation_id}/teams","GET /orgs/{org}/issues","GET /orgs/{org}/members","GET /orgs/{org}/members/{username}/codespaces","GET /orgs/{org}/migrations","GET /orgs/{org}/migrations/{migration_id}/repositories","GET /orgs/{org}/organization-roles/{role_id}/teams","GET /orgs/{org}/organization-roles/{role_id}/users","GET /orgs/{org}/outside_collaborators","GET /orgs/{org}/packages","GET /orgs/{org}/packages/{package_type}/{package_name}/versions","GET /orgs/{org}/personal-access-token-requests","GET /orgs/{org}/personal-access-token-requests/{pat_request_id}/repositories","GET /orgs/{org}/personal-access-tokens","GET /orgs/{org}/personal-access-tokens/{pat_id}/repositories","GET /orgs/{org}/private-registries","GET /orgs/{org}/projects","GET /orgs/{org}/projectsV2","GET /orgs/{org}/projectsV2/{project_number}/fields","GET /orgs/{org}/projectsV2/{project_number}/items","GET /orgs/{org}/properties/values","GET /orgs/{org}/public_members","GET /orgs/{org}/repos","GET /orgs/{org}/rulesets","GET /orgs/{org}/rulesets/rule-suites","GET /orgs/{org}/rulesets/{ruleset_id}/history","GET /orgs/{org}/secret-scanning/alerts","GET /orgs/{org}/security-advisories","GET /orgs/{org}/settings/immutable-releases/repositories","GET /orgs/{org}/settings/network-configurations","GET /orgs/{org}/team/{team_slug}/copilot/metrics","GET /orgs/{org}/teams","GET /orgs/{org}/teams/{team_slug}/discussions","GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments","GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions","GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions","GET /orgs/{org}/teams/{team_slug}/invitations","GET /orgs/{org}/teams/{team_slug}/members","GET /orgs/{org}/teams/{team_slug}/projects","GET /orgs/{org}/teams/{team_slug}/repos","GET /orgs/{org}/teams/{team_slug}/teams","GET /projects/{project_id}/collaborators","GET /repos/{owner}/{repo}/actions/artifacts","GET /repos/{owner}/{repo}/actions/caches","GET /repos/{owner}/{repo}/actions/organization-secrets","GET /repos/{owner}/{repo}/actions/organization-variables","GET /repos/{owner}/{repo}/actions/runners","GET /repos/{owner}/{repo}/actions/runs","GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts","GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs","GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs","GET /repos/{owner}/{repo}/actions/secrets","GET /repos/{owner}/{repo}/actions/variables","GET /repos/{owner}/{repo}/actions/workflows","GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs","GET /repos/{owner}/{repo}/activity","GET /repos/{owner}/{repo}/assignees","GET /repos/{owner}/{repo}/attestations/{subject_digest}","GET /repos/{owner}/{repo}/branches","GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations","GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs","GET /repos/{owner}/{repo}/code-scanning/alerts","GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances","GET /repos/{owner}/{repo}/code-scanning/analyses","GET /repos/{owner}/{repo}/codespaces","GET /repos/{owner}/{repo}/codespaces/devcontainers","GET /repos/{owner}/{repo}/codespaces/secrets","GET /repos/{owner}/{repo}/collaborators","GET /repos/{owner}/{repo}/comments","GET /repos/{owner}/{repo}/comments/{comment_id}/reactions","GET /repos/{owner}/{repo}/commits","GET /repos/{owner}/{repo}/commits/{commit_sha}/comments","GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls","GET /repos/{owner}/{repo}/commits/{ref}/check-runs","GET /repos/{owner}/{repo}/commits/{ref}/check-suites","GET /repos/{owner}/{repo}/commits/{ref}/status","GET /repos/{owner}/{repo}/commits/{ref}/statuses","GET /repos/{owner}/{repo}/compare/{basehead}","GET /repos/{owner}/{repo}/compare/{base}...{head}","GET /repos/{owner}/{repo}/contributors","GET /repos/{owner}/{repo}/dependabot/alerts","GET /repos/{owner}/{repo}/dependabot/secrets","GET /repos/{owner}/{repo}/deployments","GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses","GET /repos/{owner}/{repo}/environments","GET /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies","GET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/apps","GET /repos/{owner}/{repo}/environments/{environment_name}/secrets","GET /repos/{owner}/{repo}/environments/{environment_name}/variables","GET /repos/{owner}/{repo}/events","GET /repos/{owner}/{repo}/forks","GET /repos/{owner}/{repo}/hooks","GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries","GET /repos/{owner}/{repo}/invitations","GET /repos/{owner}/{repo}/issues","GET /repos/{owner}/{repo}/issues/comments","GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions","GET /repos/{owner}/{repo}/issues/events","GET /repos/{owner}/{repo}/issues/{issue_number}/comments","GET /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by","GET /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocking","GET /repos/{owner}/{repo}/issues/{issue_number}/events","GET /repos/{owner}/{repo}/issues/{issue_number}/labels","GET /repos/{owner}/{repo}/issues/{issue_number}/reactions","GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issues","GET /repos/{owner}/{repo}/issues/{issue_number}/timeline","GET /repos/{owner}/{repo}/keys","GET /repos/{owner}/{repo}/labels","GET /repos/{owner}/{repo}/milestones","GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels","GET /repos/{owner}/{repo}/notifications","GET /repos/{owner}/{repo}/pages/builds","GET /repos/{owner}/{repo}/projects","GET /repos/{owner}/{repo}/pulls","GET /repos/{owner}/{repo}/pulls/comments","GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions","GET /repos/{owner}/{repo}/pulls/{pull_number}/comments","GET /repos/{owner}/{repo}/pulls/{pull_number}/commits","GET /repos/{owner}/{repo}/pulls/{pull_number}/files","GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews","GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments","GET /repos/{owner}/{repo}/releases","GET /repos/{owner}/{repo}/releases/{release_id}/assets","GET /repos/{owner}/{repo}/releases/{release_id}/reactions","GET /repos/{owner}/{repo}/rules/branches/{branch}","GET /repos/{owner}/{repo}/rulesets","GET /repos/{owner}/{repo}/rulesets/rule-suites","GET /repos/{owner}/{repo}/rulesets/{ruleset_id}/history","GET /repos/{owner}/{repo}/secret-scanning/alerts","GET /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}/locations","GET /repos/{owner}/{repo}/security-advisories","GET /repos/{owner}/{repo}/stargazers","GET /repos/{owner}/{repo}/subscribers","GET /repos/{owner}/{repo}/tags","GET /repos/{owner}/{repo}/teams","GET /repos/{owner}/{repo}/topics","GET /repositories","GET /search/code","GET /search/commits","GET /search/issues","GET /search/labels","GET /search/repositories","GET /search/topics","GET /search/users","GET /teams/{team_id}/discussions","GET /teams/{team_id}/discussions/{discussion_number}/comments","GET /teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}/reactions","GET /teams/{team_id}/discussions/{discussion_number}/reactions","GET /teams/{team_id}/invitations","GET /teams/{team_id}/members","GET /teams/{team_id}/projects","GET /teams/{team_id}/repos","GET /teams/{team_id}/teams","GET /user/blocks","GET /user/codespaces","GET /user/codespaces/secrets","GET /user/emails","GET /user/followers","GET /user/following","GET /user/gpg_keys","GET /user/installations","GET /user/installations/{installation_id}/repositories","GET /user/issues","GET /user/keys","GET /user/marketplace_purchases","GET /user/marketplace_purchases/stubbed","GET /user/memberships/orgs","GET /user/migrations","GET /user/migrations/{migration_id}/repositories","GET /user/orgs","GET /user/packages","GET /user/packages/{package_type}/{package_name}/versions","GET /user/public_emails","GET /user/repos","GET /user/repository_invitations","GET /user/social_accounts","GET /user/ssh_signing_keys","GET /user/starred","GET /user/subscriptions","GET /user/teams","GET /users","GET /users/{username}/attestations/{subject_digest}","GET /users/{username}/events","GET /users/{username}/events/orgs/{org}","GET /users/{username}/events/public","GET /users/{username}/followers","GET /users/{username}/following","GET /users/{username}/gists","GET /users/{username}/gpg_keys","GET /users/{username}/keys","GET /users/{username}/orgs","GET /users/{username}/packages","GET /users/{username}/projects","GET /users/{username}/projectsV2","GET /users/{username}/projectsV2/{project_number}/fields","GET /users/{username}/projectsV2/{project_number}/items","GET /users/{username}/received_events","GET /users/{username}/received_events/public","GET /users/{username}/repos","GET /users/{username}/social_accounts","GET /users/{username}/ssh_signing_keys","GET /users/{username}/starred","GET /users/{username}/subscriptions"];function isPaginatingEndpoint(e){if(typeof e==="string"){return Ph.includes(e)}else{return false}}function paginateRest(e){return{paginate:Object.assign(paginate.bind(null,e),{iterator:iterator.bind(null,e)})}}paginateRest.VERSION=Th;const Dh=new Context;const kh=getApiBaseUrl();const _h={baseUrl:kh,request:{agent:getProxyAgent(kh),fetch:getProxyFetch(kh)}};const Lh=Octokit.plugin(restEndpointMethods,paginateRest).defaults(_h);function getOctokitOptions(e,t){const n=Object.assign({},t||{});const o=getAuthString(e,n);if(o){n.auth=o}return n}const Oh=new Context;function getOctokit(e,t,...n){const o=Lh.plugin(...n);return new o(getOctokitOptions(e,t))}class InvalidTokenError extends Error{}InvalidTokenError.prototype.name="InvalidTokenError";function b64DecodeUnicode(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();if(n.length<2){n="0"+n}return"%"+n})))}function base64UrlDecode(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return b64DecodeUnicode(t)}catch(e){return atob(t)}}function jwtDecode(e,t){if(typeof e!=="string"){throw new InvalidTokenError("Invalid token specified: must be a string")}t||(t={});const n=t.header===true?0:1;const o=e.split(".")[n];if(typeof o!=="string"){throw new InvalidTokenError(`Invalid token specified: missing part #${n+1}`)}let i;try{i=base64UrlDecode(o)}catch(e){throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new InvalidTokenError(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}class github_GitHub{githubToken;octokit;constructor(e){this.githubToken=e?.token||process.env.GITHUB_TOKEN;this.octokit=getOctokit(`${this.githubToken}`)}repoData(){return this.octokit.rest.repos.get({...Oh.repo}).then((e=>e.data))}async releases(e,t){let n;try{n=await this.releasesRaw(e,t)}catch(o){if(!this.githubToken){throw o}n=await this.releasesRaw(e,t,this.githubToken)}return n}async releasesRaw(e,t,n){const o=`https://raw.githubusercontent.com/${t.owner}/${t.repo}/${t.ref}/${t.path}`;const i=new lib_HttpClient("docker-actions-toolkit");const c=await i.get(o,n?{Authorization:`token ${n}`}:undefined);const d=await c.readBody();const p=c.message.statusCode||500;if(p>=400){throw new Error(`Failed to get ${e} releases from ${o} with status code ${p}: ${d}`)}return JSON.parse(d)}static get context(){return Oh}static get serverURL(){return process.env.GITHUB_SERVER_URL||"https://github.com"}static get apiURL(){return process.env.GITHUB_API_URL||"https://api.github.com"}static get isGHES(){const e=new URL(github_GitHub.serverURL);const t=e.hostname.trimEnd().toUpperCase();const n=t==="GITHUB.COM";const o=t.endsWith(".GHE.COM");const i=t.endsWith(".LOCALHOST");return!n&&!o&&!i}static get repository(){return`${Oh.repo.owner}/${Oh.repo.repo}`}static get workspace(){return process.env.GITHUB_WORKSPACE||process.cwd()}static get runId(){return process.env.GITHUB_RUN_ID?+process.env.GITHUB_RUN_ID:Oh.runId}static get runAttempt(){return process.env.GITHUB_RUN_ATTEMPT?+process.env.GITHUB_RUN_ATTEMPT:1}static workflowRunURL(e){return`${github_GitHub.serverURL}/${github_GitHub.repository}/actions/runs/${github_GitHub.runId}${e?`/attempts/${github_GitHub.runAttempt}`:""}`}static get actionsRuntimeToken(){const e=process.env["ACTIONS_RUNTIME_TOKEN"]||"";return e?jwtDecode(e):undefined}static async printActionsRuntimeTokenACs(){let e;try{e=github_GitHub.actionsRuntimeToken}catch(e){throw new Error(`Cannot parse GitHub Actions Runtime Token: ${e.message}`)}if(!e){throw new Error(`ACTIONS_RUNTIME_TOKEN not set`)}try{JSON.parse(`${e.ac}`).forEach((e=>{let t;switch(e.Permission){case 1:t="read";break;case 2:t="write";break;case 3:t="read/write";break;default:t=`unimplemented (${e.Permission})`}info(`${e.Scope}: ${t}`)}))}catch(e){throw new Error(`Cannot parse GitHub Actions Runtime Token ACs: ${e.message}`)}}}class context_Context{static _tmpDir=y.mkdtempSync(C.join(context_Context.ensureDirExists(process.env.RUNNER_TEMP||c.tmpdir()),"docker-actions-toolkit-"));static ensureDirExists(e){y.mkdirSync(e,{recursive:true});return e}static tmpDir(){return context_Context._tmpDir}static tmpName(e){return Ff.om(e)}static gitRef(){return context_Context.parseGitRef(Oh.ref,Oh.sha)}static parseGitRef(e,t){const n=!!(process.env.DOCKER_DEFAULT_GIT_CONTEXT_PR_HEAD_REF&&process.env.DOCKER_DEFAULT_GIT_CONTEXT_PR_HEAD_REF==="true");if(t&&e&&!e.startsWith("refs/")){e=`refs/heads/${e}`}if(t&&!e.startsWith(`refs/pull/`)){e=t}else if(e.startsWith(`refs/pull/`)&&n){e=e.replace(/\/merge$/g,"/head")}return e}static gitContext(){return`${github_GitHub.serverURL}/${Oh.repo.owner}/${Oh.repo.repo}.git#${context_Context.gitRef()}`}}class Exec{static async exec(e,t,n){core_debug(`Exec.exec: ${e} ${t?.join(" ")}`);return exec_exec(e,t,n)}static async getExecOutput(e,t,n){core_debug(`Exec.getExecOutput: ${e} ${t?.join(" ")}`);return getExecOutput(e,t,n)}}class CsvError extends Error{constructor(e,t,n,...o){if(Array.isArray(t))t=t.join(" ").trim();super(t);if(Error.captureStackTrace!==undefined){Error.captureStackTrace(this,CsvError)}this.code=e;for(const e of o){for(const t in e){const o=e[t];this[t]=Buffer.isBuffer(o)?o.toString(n.encoding):o==null?o:JSON.parse(JSON.stringify(o))}}}}const is_object=function(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)};const normalize_columns_array=function(e){const t=[];for(let n=0,o=e.length;n=this.size){this.resize();if(t>=this.size){throw Error("INVALID_BUFFER_STATE")}}const n=this.buf;this.buf=Buffer.allocUnsafe(this.size);e.copy(this.buf,0);n.copy(this.buf,e.length);this.length+=e.length}else{const t=this.length++;if(t===this.size){this.resize()}const n=this.clone();this.buf[0]=e;n.copy(this.buf,1,0,t)}}append(e){const t=this.length++;if(t===this.size){this.resize()}this.buf[t]=e}clone(){return Buffer.from(this.buf.slice(0,this.length))}resize(){const e=this.length;this.size=this.size*2;const t=Buffer.allocUnsafe(this.size);this.buf.copy(t,0,0,e);this.buf=t}toString(e){if(e){return this.buf.slice(0,this.length).toString(e)}else{return Uint8Array.prototype.slice.call(this.buf.slice(0,this.length))}}toJSON(){return this.toString("utf8")}reset(){this.length=0}}const Fh=ResizeableBuffer;const Uh=12;const Mh=13;const Hh=10;const $h=32;const Gh=9;const init_state=function(e){return{bomSkipped:false,bufBytesStart:0,castField:e.cast_function,commenting:false,error:undefined,enabled:e.from_line===1,escaping:false,escapeIsQuote:Buffer.isBuffer(e.escape)&&Buffer.isBuffer(e.quote)&&Buffer.compare(e.escape,e.quote)===0,expectedRecordLength:Array.isArray(e.columns)?e.columns.length:undefined,field:new Fh(20),firstLineToHeaders:e.cast_first_line_to_header,needMoreDataSize:Math.max(e.comment!==null?e.comment.length:0,...e.delimiter.map((e=>e.length)),e.quote!==null?e.quote.length:0),previousBuf:undefined,quoting:false,stop:false,rawBuffer:new Fh(100),record:[],recordHasError:false,record_length:0,recordDelimiterMaxLength:e.record_delimiter.length===0?0:Math.max(...e.record_delimiter.map((e=>e.length))),trimChars:[Buffer.from(" ",e.encoding)[0],Buffer.from("\t",e.encoding)[0]],wasQuoting:false,wasRowDelimiter:false,timchars:[Buffer.from(Buffer.from([Mh],"utf8").toString(),e.encoding),Buffer.from(Buffer.from([Hh],"utf8").toString(),e.encoding),Buffer.from(Buffer.from([Uh],"utf8").toString(),e.encoding),Buffer.from(Buffer.from([$h],"utf8").toString(),e.encoding),Buffer.from(Buffer.from([Gh],"utf8").toString(),e.encoding)]}};const underscore=function(e){return e.replace(/([A-Z])/g,(function(e,t){return"_"+t.toLowerCase()}))};const normalize_options=function(e){const t={};for(const n in e){t[underscore(n)]=e[n]}if(t.encoding===undefined||t.encoding===true){t.encoding="utf8"}else if(t.encoding===null||t.encoding===false){t.encoding=null}else if(typeof t.encoding!=="string"&&t.encoding!==null){throw new CsvError("CSV_INVALID_OPTION_ENCODING",["Invalid option encoding:","encoding must be a string or null to return a buffer,",`got ${JSON.stringify(t.encoding)}`],t)}if(t.bom===undefined||t.bom===null||t.bom===false){t.bom=false}else if(t.bom!==true){throw new CsvError("CSV_INVALID_OPTION_BOM",["Invalid option bom:","bom must be true,",`got ${JSON.stringify(t.bom)}`],t)}t.cast_function=null;if(t.cast===undefined||t.cast===null||t.cast===false||t.cast===""){t.cast=undefined}else if(typeof t.cast==="function"){t.cast_function=t.cast;t.cast=true}else if(t.cast!==true){throw new CsvError("CSV_INVALID_OPTION_CAST",["Invalid option cast:","cast must be true or a function,",`got ${JSON.stringify(t.cast)}`],t)}if(t.cast_date===undefined||t.cast_date===null||t.cast_date===false||t.cast_date===""){t.cast_date=false}else if(t.cast_date===true){t.cast_date=function(e){const t=Date.parse(e);return!isNaN(t)?new Date(t):e}}else if(typeof t.cast_date!=="function"){throw new CsvError("CSV_INVALID_OPTION_CAST_DATE",["Invalid option cast_date:","cast_date must be true or a function,",`got ${JSON.stringify(t.cast_date)}`],t)}t.cast_first_line_to_header=undefined;if(t.columns===true){t.cast_first_line_to_header=undefined}else if(typeof t.columns==="function"){t.cast_first_line_to_header=t.columns;t.columns=true}else if(Array.isArray(t.columns)){t.columns=normalize_columns_array(t.columns)}else if(t.columns===undefined||t.columns===null||t.columns===false){t.columns=false}else{throw new CsvError("CSV_INVALID_OPTION_COLUMNS",["Invalid option columns:","expect an array, a function or true,",`got ${JSON.stringify(t.columns)}`],t)}if(t.group_columns_by_name===undefined||t.group_columns_by_name===null||t.group_columns_by_name===false){t.group_columns_by_name=false}else if(t.group_columns_by_name!==true){throw new CsvError("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","expect an boolean,",`got ${JSON.stringify(t.group_columns_by_name)}`],t)}else if(t.columns===false){throw new CsvError("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","the `columns` mode must be activated."],t)}if(t.comment===undefined||t.comment===null||t.comment===false||t.comment===""){t.comment=null}else{if(typeof t.comment==="string"){t.comment=Buffer.from(t.comment,t.encoding)}if(!Buffer.isBuffer(t.comment)){throw new CsvError("CSV_INVALID_OPTION_COMMENT",["Invalid option comment:","comment must be a buffer or a string,",`got ${JSON.stringify(t.comment)}`],t)}}if(t.comment_no_infix===undefined||t.comment_no_infix===null||t.comment_no_infix===false){t.comment_no_infix=false}else if(t.comment_no_infix!==true){throw new CsvError("CSV_INVALID_OPTION_COMMENT",["Invalid option comment_no_infix:","value must be a boolean,",`got ${JSON.stringify(t.comment_no_infix)}`],t)}const n=JSON.stringify(t.delimiter);if(!Array.isArray(t.delimiter))t.delimiter=[t.delimiter];if(t.delimiter.length===0){throw new CsvError("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${n}`],t)}t.delimiter=t.delimiter.map((function(e){if(e===undefined||e===null||e===false){return Buffer.from(",",t.encoding)}if(typeof e==="string"){e=Buffer.from(e,t.encoding)}if(!Buffer.isBuffer(e)||e.length===0){throw new CsvError("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${n}`],t)}return e}));if(t.escape===undefined||t.escape===true){t.escape=Buffer.from('"',t.encoding)}else if(typeof t.escape==="string"){t.escape=Buffer.from(t.escape,t.encoding)}else if(t.escape===null||t.escape===false){t.escape=null}if(t.escape!==null){if(!Buffer.isBuffer(t.escape)){throw new Error(`Invalid Option: escape must be a buffer, a string or a boolean, got ${JSON.stringify(t.escape)}`)}}if(t.from===undefined||t.from===null){t.from=1}else{if(typeof t.from==="string"&&/\d+/.test(t.from)){t.from=parseInt(t.from)}if(Number.isInteger(t.from)){if(t.from<0){throw new Error(`Invalid Option: from must be a positive integer, got ${JSON.stringify(e.from)}`)}}else{throw new Error(`Invalid Option: from must be an integer, got ${JSON.stringify(t.from)}`)}}if(t.from_line===undefined||t.from_line===null){t.from_line=1}else{if(typeof t.from_line==="string"&&/\d+/.test(t.from_line)){t.from_line=parseInt(t.from_line)}if(Number.isInteger(t.from_line)){if(t.from_line<=0){throw new Error(`Invalid Option: from_line must be a positive integer greater than 0, got ${JSON.stringify(e.from_line)}`)}}else{throw new Error(`Invalid Option: from_line must be an integer, got ${JSON.stringify(e.from_line)}`)}}if(t.ignore_last_delimiters===undefined||t.ignore_last_delimiters===null){t.ignore_last_delimiters=false}else if(typeof t.ignore_last_delimiters==="number"){t.ignore_last_delimiters=Math.floor(t.ignore_last_delimiters);if(t.ignore_last_delimiters===0){t.ignore_last_delimiters=false}}else if(typeof t.ignore_last_delimiters!=="boolean"){throw new CsvError("CSV_INVALID_OPTION_IGNORE_LAST_DELIMITERS",["Invalid option `ignore_last_delimiters`:","the value must be a boolean value or an integer,",`got ${JSON.stringify(t.ignore_last_delimiters)}`],t)}if(t.ignore_last_delimiters===true&&t.columns===false){throw new CsvError("CSV_IGNORE_LAST_DELIMITERS_REQUIRES_COLUMNS",["The option `ignore_last_delimiters`","requires the activation of the `columns` option"],t)}if(t.info===undefined||t.info===null||t.info===false){t.info=false}else if(t.info!==true){throw new Error(`Invalid Option: info must be true, got ${JSON.stringify(t.info)}`)}if(t.max_record_size===undefined||t.max_record_size===null||t.max_record_size===false){t.max_record_size=0}else if(Number.isInteger(t.max_record_size)&&t.max_record_size>=0){}else if(typeof t.max_record_size==="string"&&/\d+/.test(t.max_record_size)){t.max_record_size=parseInt(t.max_record_size)}else{throw new Error(`Invalid Option: max_record_size must be a positive integer, got ${JSON.stringify(t.max_record_size)}`)}if(t.objname===undefined||t.objname===null||t.objname===false){t.objname=undefined}else if(Buffer.isBuffer(t.objname)){if(t.objname.length===0){throw new Error(`Invalid Option: objname must be a non empty buffer`)}if(t.encoding===null){}else{t.objname=t.objname.toString(t.encoding)}}else if(typeof t.objname==="string"){if(t.objname.length===0){throw new Error(`Invalid Option: objname must be a non empty string`)}}else if(typeof t.objname==="number"){}else{throw new Error(`Invalid Option: objname must be a string or a buffer, got ${t.objname}`)}if(t.objname!==undefined){if(typeof t.objname==="number"){if(t.columns!==false){throw Error("Invalid Option: objname index cannot be combined with columns or be defined as a field")}}else{if(t.columns===false){throw Error("Invalid Option: objname field must be combined with columns or be defined as an index")}}}if(t.on_record===undefined||t.on_record===null){t.on_record=undefined}else if(typeof t.on_record!=="function"){throw new CsvError("CSV_INVALID_OPTION_ON_RECORD",["Invalid option `on_record`:","expect a function,",`got ${JSON.stringify(t.on_record)}`],t)}if(t.on_skip!==undefined&&t.on_skip!==null&&typeof t.on_skip!=="function"){throw new Error(`Invalid Option: on_skip must be a function, got ${JSON.stringify(t.on_skip)}`)}if(t.quote===null||t.quote===false||t.quote===""){t.quote=null}else{if(t.quote===undefined||t.quote===true){t.quote=Buffer.from('"',t.encoding)}else if(typeof t.quote==="string"){t.quote=Buffer.from(t.quote,t.encoding)}if(!Buffer.isBuffer(t.quote)){throw new Error(`Invalid Option: quote must be a buffer or a string, got ${JSON.stringify(t.quote)}`)}}if(t.raw===undefined||t.raw===null||t.raw===false){t.raw=false}else if(t.raw!==true){throw new Error(`Invalid Option: raw must be true, got ${JSON.stringify(t.raw)}`)}if(t.record_delimiter===undefined){t.record_delimiter=[]}else if(typeof t.record_delimiter==="string"||Buffer.isBuffer(t.record_delimiter)){if(t.record_delimiter.length===0){throw new CsvError("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer,",`got ${JSON.stringify(t.record_delimiter)}`],t)}t.record_delimiter=[t.record_delimiter]}else if(!Array.isArray(t.record_delimiter)){throw new CsvError("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer,",`got ${JSON.stringify(t.record_delimiter)}`],t)}t.record_delimiter=t.record_delimiter.map((function(e,n){if(typeof e!=="string"&&!Buffer.isBuffer(e)){throw new CsvError("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer",`at index ${n},`,`got ${JSON.stringify(e)}`],t)}else if(e.length===0){throw new CsvError("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer",`at index ${n},`,`got ${JSON.stringify(e)}`],t)}if(typeof e==="string"){e=Buffer.from(e,t.encoding)}return e}));if(typeof t.relax_column_count==="boolean"){}else if(t.relax_column_count===undefined||t.relax_column_count===null){t.relax_column_count=false}else{throw new Error(`Invalid Option: relax_column_count must be a boolean, got ${JSON.stringify(t.relax_column_count)}`)}if(typeof t.relax_column_count_less==="boolean"){}else if(t.relax_column_count_less===undefined||t.relax_column_count_less===null){t.relax_column_count_less=false}else{throw new Error(`Invalid Option: relax_column_count_less must be a boolean, got ${JSON.stringify(t.relax_column_count_less)}`)}if(typeof t.relax_column_count_more==="boolean"){}else if(t.relax_column_count_more===undefined||t.relax_column_count_more===null){t.relax_column_count_more=false}else{throw new Error(`Invalid Option: relax_column_count_more must be a boolean, got ${JSON.stringify(t.relax_column_count_more)}`)}if(typeof t.relax_quotes==="boolean"){}else if(t.relax_quotes===undefined||t.relax_quotes===null){t.relax_quotes=false}else{throw new Error(`Invalid Option: relax_quotes must be a boolean, got ${JSON.stringify(t.relax_quotes)}`)}if(typeof t.skip_empty_lines==="boolean"){}else if(t.skip_empty_lines===undefined||t.skip_empty_lines===null){t.skip_empty_lines=false}else{throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(t.skip_empty_lines)}`)}if(typeof t.skip_records_with_empty_values==="boolean"){}else if(t.skip_records_with_empty_values===undefined||t.skip_records_with_empty_values===null){t.skip_records_with_empty_values=false}else{throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(t.skip_records_with_empty_values)}`)}if(typeof t.skip_records_with_error==="boolean"){}else if(t.skip_records_with_error===undefined||t.skip_records_with_error===null){t.skip_records_with_error=false}else{throw new Error(`Invalid Option: skip_records_with_error must be a boolean, got ${JSON.stringify(t.skip_records_with_error)}`)}if(t.rtrim===undefined||t.rtrim===null||t.rtrim===false){t.rtrim=false}else if(t.rtrim!==true){throw new Error(`Invalid Option: rtrim must be a boolean, got ${JSON.stringify(t.rtrim)}`)}if(t.ltrim===undefined||t.ltrim===null||t.ltrim===false){t.ltrim=false}else if(t.ltrim!==true){throw new Error(`Invalid Option: ltrim must be a boolean, got ${JSON.stringify(t.ltrim)}`)}if(t.trim===undefined||t.trim===null||t.trim===false){t.trim=false}else if(t.trim!==true){throw new Error(`Invalid Option: trim must be a boolean, got ${JSON.stringify(t.trim)}`)}if(t.trim===true&&e.ltrim!==false){t.ltrim=true}else if(t.ltrim!==true){t.ltrim=false}if(t.trim===true&&e.rtrim!==false){t.rtrim=true}else if(t.rtrim!==true){t.rtrim=false}if(t.to===undefined||t.to===null){t.to=-1}else if(t.to!==-1){if(typeof t.to==="string"&&/\d+/.test(t.to)){t.to=parseInt(t.to)}if(Number.isInteger(t.to)){if(t.to<=0){throw new Error(`Invalid Option: to must be a positive integer greater than 0, got ${JSON.stringify(e.to)}`)}}else{throw new Error(`Invalid Option: to must be an integer, got ${JSON.stringify(e.to)}`)}}if(t.to_line===undefined||t.to_line===null){t.to_line=-1}else if(t.to_line!==-1){if(typeof t.to_line==="string"&&/\d+/.test(t.to_line)){t.to_line=parseInt(t.to_line)}if(Number.isInteger(t.to_line)){if(t.to_line<=0){throw new Error(`Invalid Option: to_line must be a positive integer greater than 0, got ${JSON.stringify(e.to_line)}`)}}else{throw new Error(`Invalid Option: to_line must be an integer, got ${JSON.stringify(e.to_line)}`)}}return t};const isRecordEmpty=function(e){return e.every((e=>e==null||e.toString&&e.toString().trim()===""))};const qh=13;const zh=10;const Vh={utf8:Buffer.from([239,187,191]),utf16le:Buffer.from([255,254])};const transform=function(e={}){const t={bytes:0,comment_lines:0,empty_lines:0,invalid_field_length:0,lines:1,records:0};const n=normalize_options(e);return{info:t,original_options:e,options:n,state:init_state(n),__needMoreData:function(e,t,n){if(n)return false;const{encoding:o,escape:i,quote:c}=this.options;const{quoting:d,needMoreDataSize:p,recordDelimiterMaxLength:y}=this.state;const C=t-e-1;const Q=Math.max(p,y===0?Buffer.from("\r\n",o).length:y,d?(i===null?0:i.length)+c.length:0,d?c.length+y:0);return CV){this.state.stop=true;o();return}if(this.state.quoting===false&&ne.length===0){const e=this.__autoDiscoverRecordDelimiter(ce,ue);if(e){ne=this.options.record_delimiter}}const e=ce[ue];if(Q===true){ie.append(e)}if((e===qh||e===zh)&&this.state.wasRowDelimiter===false){this.state.wasRowDelimiter=true}if(this.state.escaping===true){this.state.escaping=false}else{if(te!==null&&this.state.quoting===true&&this.__isEscape(ce,ue,e)&&ue+te.lengthVh[e].equals(this.state.field.toString())?e:false)).filter(Boolean)[0];const n=this.__error(new CsvError("INVALID_OPENING_QUOTE",["Invalid Opening Quote:",`a quote is found on field ${JSON.stringify(e.column)} at line ${e.lines}, value is ${JSON.stringify(this.state.field.toString(d))}`,t?`(${t} bom)`:undefined],this.options,e,{field:this.state.field}));if(n!==undefined)return n}}else{this.state.quoting=true;ue+=re.length-1;continue}}}if(this.state.quoting===false){const t=this.__isRecordDelimiter(e,ce,ue);if(t!==0){const e=this.state.commenting&&this.state.wasQuoting===false&&this.state.record.length===0&&this.state.field.length===0;if(e){this.info.comment_lines++}else{if(this.state.enabled===false&&this.info.lines+(this.state.wasRowDelimiter===true?1:0)>=p){this.state.enabled=true;this.__resetField();this.__resetRecord();ue+=t-1;continue}if(k===true&&this.state.wasQuoting===false&&this.state.record.length===0&&this.state.field.length===0){this.info.empty_lines++;ue+=t-1;continue}this.info.bytes=this.state.bufBytesStart+ue;const e=this.__onField();if(e!==undefined)return e;this.info.bytes=this.state.bufBytesStart+ue+t;const i=this.__onRecord(n);if(i!==undefined)return i;if($!==-1&&this.info.records>=$){this.state.stop=true;o();return}}this.state.commenting=false;ue+=t-1;continue}if(this.state.commenting){continue}if(ee!==null&&(c===false||this.state.record.length===0&&this.state.field.length===0)){const t=this.__compareBytes(ee,ce,ue,e);if(t!==0){this.state.commenting=true;continue}}const i=this.__isDelimiter(ce,ue,e);if(i!==0){this.info.bytes=this.state.bufBytesStart+ue;const e=this.__onField();if(e!==undefined)return e;ue+=i-1;continue}}}if(this.state.commenting===false){if(C!==0&&this.state.record_length+this.state.field.length>C){return this.__error(new CsvError("CSV_MAX_RECORD_SIZE",["Max Record Size:","record exceed the maximum number of tolerated bytes",`of ${C}`,`at line ${this.info.lines}`],this.options,this.__infoField()))}}const i=y===false||this.state.quoting===true||this.state.field.length!==0||!this.__isCharTrimable(ce,ue);const se=D===false||this.state.wasQuoting===false;if(i===true&&se===true){this.state.field.append(e)}else if(D===true&&!this.__isCharTrimable(ce,ue)){return this.__error(new CsvError("CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE",["Invalid Closing Quote:","found non trimable byte after quote",`at line ${this.info.lines}`],this.options,this.__infoField()))}else{if(i===false){ue+=this.__isCharTrimable(ce,ue)-1}continue}}if(t===true){if(this.state.quoting===true){const e=this.__error(new CsvError("CSV_QUOTE_NOT_CLOSED",["Quote Not Closed:",`the parsing is finished with an opening quote at line ${this.info.lines}`],this.options,this.__infoField()));if(e!==undefined)return e}else{if(this.state.wasQuoting===true||this.state.record.length!==0||this.state.field.length!==0){this.info.bytes=this.state.bufBytesStart+ue;const e=this.__onField();if(e!==undefined)return e;const t=this.__onRecord(n);if(t!==undefined)return t}else if(this.state.wasRowDelimiter===true){this.info.empty_lines++}else if(this.state.commenting===true){this.info.comment_lines++}}}else{this.state.bufBytesStart+=ue;this.state.previousBuf=ce.slice(ue)}if(this.state.wasRowDelimiter===true){this.info.lines++;this.state.wasRowDelimiter=false}},__onRecord:function(e){const{columns:t,group_columns_by_name:n,encoding:o,info:i,from:c,relax_column_count:d,relax_column_count_less:p,relax_column_count_more:y,raw:C,skip_records_with_empty_values:Q}=this.options;const{enabled:v,record:D}=this.state;if(v===false){return this.__resetRecord()}const k=D.length;if(t===true){if(Q===true&&isRecordEmpty(D)){this.__resetRecord();return}return this.__firstLineToColumns(D)}if(t===false&&this.info.records===0){this.state.expectedRecordLength=k}if(k!==this.state.expectedRecordLength){const e=t===false?new CsvError("CSV_RECORD_INCONSISTENT_FIELDS_LENGTH",["Invalid Record Length:",`expect ${this.state.expectedRecordLength},`,`got ${k} on line ${this.info.lines}`],this.options,this.__infoField(),{record:D}):new CsvError("CSV_RECORD_INCONSISTENT_COLUMNS",["Invalid Record Length:",`columns length is ${t.length},`,`got ${k} on line ${this.info.lines}`],this.options,this.__infoField(),{record:D});if(d===true||p===true&&kthis.state.expectedRecordLength){this.info.invalid_field_length++;this.state.error=e}else{const t=this.__error(e);if(t)return t}}if(Q===true&&isRecordEmpty(D)){this.__resetRecord();return}if(this.state.recordHasError===true){this.__resetRecord();this.state.recordHasError=false;return}this.info.records++;if(c===1||this.info.records>=c){const{objname:c}=this.options;if(t!==false){const d={};for(let e=0,o=D.length;e{const{timchars:n}=this.state;e:for(let o=0;o=0},__compareBytes:function(e,t,n,o){if(e[0]!==o)return 0;const i=e.length;for(let o=1;othis.state.record.length?e[this.state.record.length].name:null:this.state.record.length,quoting:this.state.wasQuoting}}}};const sync_parse=function(e,t={}){if(typeof e==="string"){e=Buffer.from(e)}const n=t&&t.objname?{}:[];const o=transform(t);const push=e=>{if(o.options.objname===undefined)n.push(e);else{n[e[0]]=e[1]}};const close=()=>{};const i=o.parse(e,true,push,close);if(i!==undefined)throw i;return n};class Util{static getInputList(e,t){return this.getList(getInput(e),t)}static getList(e,t){const n=[];if(e==""){return n}const o=sync_parse(e,{columns:false,relaxQuotes:true,comment:t?.comment,comment_no_infix:t?.commentNoInfix,relaxColumnCount:true,skipEmptyLines:true,quote:t?.quote});for(const e of o){if(e.length==1){if(t?.ignoreComma){n.push(e[0])}else{n.push(...e[0].split(","))}}else if(!t?.ignoreComma){n.push(...e)}else{n.push(e.join(","))}}return n.filter((e=>e)).map((e=>e.trim()))}static getInputNumber(e){const t=getInput(e);if(!t){return undefined}return parseInt(t)}static async asyncForEach(e,t){for(let n=0;nsetTimeout(t,e*1e3)))}static hash(e){return p.createHash("sha256").update(e).digest("hex")}static parseBool(e){switch(e){case"1":case"t":case"T":case"true":case"TRUE":case"True":return true;case"0":case"f":case"F":case"false":case"FALSE":case"False":return false;default:throw new Error(`parseBool syntax error: ${e}`)}}static formatFileSize(e){if(e===0)return"0 Bytes";const t=1024;const n=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];const o=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,o)).toFixed(2))+" "+n[o]}static generateRandomString(e=10){const t=p.randomBytes(Math.ceil(e/2));return t.toString("hex").slice(0,e)}static stringToUnicodeEntities(e){return Array.from(e).map((e=>`&#x${e.charCodeAt(0).toString(16)};`)).join("")}static countLines(e){return e.split(/\r\n|\r|\n/).length}static isPathRelativeTo(e,t){const n=C.resolve(e);const o=C.resolve(t);return o.startsWith(n.endsWith(C.sep)?n:`${n}${C.sep}`)}static formatDuration(e){if(e===0)return"0s";const t=Math.floor(e/1e9);const n=Math.floor(t/3600);const o=Math.floor(t%3600/60);const i=t%60;const c=[];if(n)c.push(`${n}h`);if(o)c.push(`${o}m`);if(i||c.length===0)c.push(`${i}s`);return c.join("")}}class Docker{static get configDir(){return process.env.DOCKER_CONFIG||C.join(c.homedir(),".docker")}static configFile(){const e=C.join(Docker.configDir,"config.json");if(!y.existsSync(e)){return undefined}return JSON.parse(y.readFileSync(e,{encoding:"utf-8"}))}static async isAvailable(){return await which("docker",true).then((e=>{core_debug(`Docker.isAvailable ok: ${e}`);return true})).catch((e=>{core_debug(`Docker.isAvailable error: ${e}`);return false}))}static async isDaemonRunning(){try{await Docker.getExecOutput([`version`],{silent:true});return true}catch{return false}}static async exec(e,t){return Exec.exec("docker",e,Docker.execOptions(t))}static async getExecOutput(e,t){return Exec.getExecOutput("docker",e,Docker.execOptions(t))}static execOptions(e){if(!e){e={}}if(!e.env){e.env=Object.assign({},process.env,{DOCKER_CONTENT_TRUST:"false"})}else{e.env.DOCKER_CONTENT_TRUST="false"}return e}static async context(e){const t=["context","inspect","--format","{{.Name}}"];if(e){t.push(e)}return await Docker.getExecOutput(t,{ignoreReturnCode:true,silent:true}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){throw new Error(e.stderr)}return e.stdout.trim()}))}static async contextInspect(e){const t=["context","inspect","--format=json"];if(e){t.push(e)}return await Docker.getExecOutput(t,{ignoreReturnCode:true,silent:true}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){throw new Error(e.stderr.trim())}return JSON.parse(e.stdout.trim())[0]}))}static async printVersion(){await Docker.exec(["version"])}static async printInfo(){await Docker.exec(["info"])}static parseRepoTag(e){let t;const n=e.indexOf("@");const o=e.lastIndexOf(":");if(n>=0){t=n}else if(o>=0){t=o}else{return{repository:e,tag:"latest"}}const i=e.slice(t+1);if(i.indexOf("/")===-1){return{repository:e.slice(0,t),tag:i}}return{repository:e,tag:"latest"}}static async pull(e,t){const n=Docker.parseRepoTag(e);const o=n.repository.replace(/[^a-zA-Z0-9.]+/g,"--");const i=n.tag.replace(/[^a-zA-Z0-9.]+/g,"--");const c=new Cache({htcName:o,htcVersion:i,baseCacheDir:C.join(Docker.configDir,".cache","images",o),cacheFile:"image.tar"});let d;if(t){d=await c.find();if(d){info(`Image found from cache in ${d}`);await Docker.getExecOutput(["load","-i",d],{ignoreReturnCode:true}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){warning(`Failed to load image from cache: ${e.stderr.match(/(.*)\s*$/)?.[0]?.trim()??"unknown error"}`)}}))}}let p=true;await Docker.getExecOutput(["pull",e],{ignoreReturnCode:true}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){p=false;const t=e.stderr.match(/(.*)\s*$/)?.[0]?.trim()??"unknown error";if(d){warning(`Failed to pull image, using one from cache: ${t}`)}else{throw new Error(t)}}}));if(t&&p){const t=C.join(context_Context.tmpDir(),`${Util.hash(e)}.tar`);await Docker.getExecOutput(["save","-o",t,e],{ignoreReturnCode:true}).then((async e=>{if(e.stderr.length>0&&e.exitCode!=0){warning(`Failed to save image: ${e.stderr.match(/(.*)\s*$/)?.[0]?.trim()??"unknown error"}`)}else{const e=await c.save(t);info(`Image cached to ${e}`)}}))}}}class Buildx{_version;_versionOnce;_standalone;static containerNamePrefix="buildx_buildkit_";constructor(e){this._standalone=e?.standalone;this._version="";this._versionOnce=false}static get configDir(){return process.env.BUILDX_CONFIG||C.join(Docker.configDir,"buildx")}static get refsDir(){return C.join(Buildx.configDir,"refs")}static get refsGroupDir(){return C.join(Buildx.refsDir,"__group__")}static get certsDir(){return C.join(Buildx.configDir,"certs")}async isStandalone(){const e=this._standalone??!await Docker.isAvailable();core_debug(`Buildx.isStandalone: ${e}`);return e}async getCommand(e){const t=await this.isStandalone();return{command:t?"buildx":"docker",args:t?e:["buildx",...e]}}async isAvailable(){const e=await this.getCommand([]);const t=await Exec.getExecOutput(e.command,e.args,{ignoreReturnCode:true,silent:true}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){core_debug(`Buildx.isAvailable cmd err: ${e.stderr.trim()}`);return false}return e.exitCode==0})).catch((e=>{core_debug(`Buildx.isAvailable error: ${e}`);return false}));core_debug(`Buildx.isAvailable: ${t}`);return t}async version(){if(this._versionOnce){return this._version}this._versionOnce=true;const e=await this.getCommand(["version"]);this._version=await Exec.getExecOutput(e.command,e.args,{ignoreReturnCode:true,silent:true}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){throw new Error(e.stderr.trim())}return Buildx.parseVersion(e.stdout.trim())}));return this._version}async printVersion(){const e=await this.getCommand(["version"]);await Exec.exec(e.command,e.args,{failOnStdErr:false})}static parseVersion(e){const t=/\sv?([0-9a-f]{7}|[0-9.]+)/.exec(e);if(!t){throw new Error(`Cannot parse buildx version`)}return t[1]}async versionSatisfies(e,t){const n=t??await this.version();if(!n){core_debug(`Buildx.versionSatisfies false: undefined version`);return false}const o=Of.satisfies(n,e)||/^[0-9a-f]{7}$/.exec(n)!==null;core_debug(`Buildx.versionSatisfies ${n} statisfies ${e}: ${o}`);return o}static resolveCertsDriverOpts(e,t,n){let o;try{o=new URL(t)}catch{return[]}if(o.protocol!="tcp:"){return[]}const i=[];if(Object.keys(n).length==0){return i}let c=o.hostname;if(o.port.length>0){c+=`-${o.port}`}if(n.cacert!==undefined){const e=C.join(Buildx.certsDir,`cacert_${c}.pem`);y.writeFileSync(e,n.cacert);i.push(`cacert=${e}`)}if(n.cert!==undefined){const e=C.join(Buildx.certsDir,`cert_${c}.pem`);y.writeFileSync(e,n.cert);i.push(`cert=${e}`)}if(n.key!==undefined){const e=C.join(Buildx.certsDir,`key_${c}.pem`);y.writeFileSync(e,n.key);i.push(`key=${e}`)}if(e!="remote"){return[]}return i}static localState(e,t){const[n,o,i]=e.split("/");if(!n||!o||!i){throw new Error(`Invalid build reference: ${e}`)}const c=C.join(t||Buildx.refsDir,n,o,i);if(!y.existsSync(c)){throw new Error(`Local state not found in ${c}`)}return Buildx.fixLocalState(JSON.parse(y.readFileSync(c,"utf8")))}static fixLocalState(e){const fnTrimToValidContext=function(e){const t=e.match(/(.*)(https?:\/{1,2}\S+|ssh:\/{1,2}\S+|git:\/{1,2}\S+)/i);if(t&&t.length==3){const e=t[1];let n=t[2];if(n.startsWith("https:/")&&!n.startsWith("https://")){n=n.replace("https:/","https://")}if(n.startsWith("http:/")&&!n.startsWith("http://")){n=n.replace("http:/","http://")}if(n.startsWith("ssh:/")&&!n.startsWith("ssh://")){n=n.replace("ssh:/","ssh://")}if(n.startsWith("git:/")&&!n.startsWith("git://")){n=n.replace("git:/","git://")}return[n,e,true]}return[e,"",false]};const[t,n,o]=fnTrimToValidContext(e.LocalPath);if(o){e.LocalPath=t;if(e.DockerfilePath.indexOf(n)===0){e.DockerfilePath=e.DockerfilePath.substring(n.length)}}e.LocalPath=e.LocalPath.endsWith("/-")?"-":e.LocalPath;e.DockerfilePath=e.DockerfilePath.endsWith("/-")?"-":e.DockerfilePath;return e}static refs(e,t={}){const{dir:n,builderName:o,nodeName:i,since:c}=e;let d=C.resolve(n);if(e.builderName){d=C.join(d,e.builderName)}if(e.nodeName){d=C.join(d,e.nodeName)}if(!y.existsSync(d)){return t}const p=y.readdirSync(d);for(const n of p){const p=C.join(d,n);const Q=y.statSync(p);if(Q.isDirectory()){const c={...e};if(!o){if(n==="__group__"){continue}c.builderName=n}else if(!i){c.nodeName=n}Buildx.refs(c,t)}else{if(c&&Q.mtimeatob(e))).join(" ");let d=atob(t.short).replace(/\s\(line \d+\)$/,"");if(t.url){d+=`\nMore info: ${t.url}`}const p=t.range&&t.range.length>0?t.range[0]?.start.line:undefined;let y=false;for(const t of o){if(t.remote||t.path.endsWith(e)&&t.content===n){i.push({title:c,message:d,file:t.path,startLine:p});y=true;break}}if(!y){core_debug(`Buildx.convertWarningsToGitHubAnnotations: skipping warning without matching Dockerfile ${e}: ${c}`)}}return i}}function getInputs(){return{registry:getInput("registry"),username:getInput("username"),password:getInput("password"),scope:getInput("scope"),ecr:getInput("ecr"),logout:getBooleanInput("logout"),registryAuth:getInput("registry-auth")}}function getAuthList(e){if(e.registryAuth&&(e.registry||e.username||e.password||e.scope||e.ecr)){throw new Error("Cannot use registry-auth with other inputs")}let t=[];if(!e.registryAuth){t.push({registry:e.registry||"docker.io",username:e.username,password:e.password,scope:e.scope,ecr:e.ecr||"auto",configDir:scopeToConfigDir(e.registry,e.scope)})}else{t=Qf(e.registryAuth).map((e=>{core_setSecret(e.password);return{registry:e.registry||"docker.io",username:e.username,password:e.password,scope:e.scope,ecr:e.ecr||"auto",configDir:scopeToConfigDir(e.registry||"docker.io",e.scope)}}))}if(t.length==0){throw new Error("No registry to login")}return t}function scopeToConfigDir(e,t){if(scopeDisabled()||!t||t===""){return""}let n=Q().join(Buildx.configDir,"config",e==="docker.io"?"registry-1.docker.io":e);if(t.startsWith("@")){n+=t}else{n=Q().join(n,t)}return n}function scopeDisabled(){if(process.env.DOCKER_LOGIN_SCOPE_DISABLED){return Util.parseBool(process.env.DOCKER_LOGIN_SCOPE_DISABLED)}return false}var jh=__nccwpck_require__(8249);var Yh=__nccwpck_require__(9821);var Jh=__nccwpck_require__(1279);const Wh=/^(([0-9]{12})\.(dkr\.ecr|dkr-ecr)\.(.+)\.(on\.aws|amazonaws\.(com(.cn)?|eu)))(\/([^:]+)(:.+)?)?$/;const Kh=/public\.ecr\.aws|ecr-public\.aws\.com/;const isECR=e=>Wh.test(e)||isPubECR(e);const isPubECR=e=>Kh.test(e);const getRegion=e=>{if(isPubECR(e)){return process.env.AWS_REGION||process.env.AWS_DEFAULT_REGION||"us-east-1"}const t=e.match(Wh);if(!t){return""}return t[4]};const getAccountIDs=e=>{if(isPubECR(e)){return[]}const t=e.match(Wh);if(!t){return[]}const n=[t[2]];if(process.env.AWS_ACCOUNT_IDS){n.push(...process.env.AWS_ACCOUNT_IDS.split(","))}return n.filter(((e,t)=>n.indexOf(e)===t))};const getRegistriesData=async(e,t,n)=>{const o=getRegion(e);const i=getAccountIDs(e);const c={};if(i.length>0){core_debug(`Requesting AWS ECR auth token for ${i.join(", ")}`);c["registryIds"]=i}let d;const p=process.env.http_proxy||process.env.HTTP_PROXY||"";if(p){core_debug(`Using http proxy ${p}`);d=new Jr.HttpProxyAgent(p)}let y;const C=process.env.https_proxy||process.env.HTTPS_PROXY||"";if(C){core_debug(`Using https proxy ${C}`);y=new Yr.HttpsProxyAgent(C)}const Q=t&&n?{accessKeyId:t,secretAccessKey:n}:undefined;if(isPubECR(e)){info(`AWS Public ECR detected with ${o} region`);const e=new Yh.ECRPUBLIC({customUserAgent:"docker-login-action",credentials:Q,region:o,requestHandler:new Jh.NodeHttpHandler({httpAgent:d,httpsAgent:y})});const t=await e.getAuthorizationToken(c);if(!t.authorizationData||!t.authorizationData.authorizationToken){throw new Error("Could not retrieve an authorization token from AWS Public ECR")}const n=Buffer.from(t.authorizationData.authorizationToken,"base64").toString("utf-8");const i=n.split(":",2);core_setSecret(i[0]);core_setSecret(i[1]);return[{registry:"public.ecr.aws",username:i[0],password:i[1]}]}else{info(`AWS ECR detected with ${o} region`);const e=new jh.ECR({customUserAgent:"docker-login-action",credentials:Q,region:o,requestHandler:new Jh.NodeHttpHandler({httpAgent:d,httpsAgent:y})});const t=await e.getAuthorizationToken(c);if(!Array.isArray(t.authorizationData)||!t.authorizationData.length){throw new Error("Could not retrieve an authorization token from AWS ECR")}const n=[];for(const e of t.authorizationData){const t=Buffer.from(e.authorizationToken||"","base64").toString("utf-8");const o=t.split(":",2);core_setSecret(o[0]);core_setSecret(o[1]);n.push({registry:e.proxyEndpoint||"",username:o[0],password:o[1]})}return n}};async function login(e){if(/true/i.test(e.ecr)||e.ecr=="auto"&&isECR(e.registry)){await loginECR(e.registry,e.username,e.password,e.scope)}else{await loginStandard(e.registry,e.username,e.password,e.scope)}}async function logout(e,t){let n;if(t!==""){n=Object.assign({},process.env,{DOCKER_CONFIG:t});info(`Alternative config dir: ${t}`)}await Docker.getExecOutput(["logout",e],{ignoreReturnCode:true,env:n}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){warning(e.stderr.trim())}}))}async function loginStandard(e,t,n,o){if(!t&&!n){throw new Error("Username and password required")}if(!t){throw new Error("Username required")}if(!n){throw new Error("Password required")}await loginExec(e,t,n,o)}async function loginECR(e,t,n,o){info(`Retrieving registries data through AWS SDK...`);const i=await getRegistriesData(e,t,n);for(const e of i){await loginExec(e.registry,e.username,e.password,o)}}async function loginExec(e,t,n,o){let i;const c=scopeToConfigDir(e,o);if(c!==""){i=Object.assign({},process.env,{DOCKER_CONFIG:c});info(`Logging into ${e} (scope ${o})...`)}else{info(`Logging into ${e}...`)}await Docker.getExecOutput(["login","--password-stdin","--username",t,e],{ignoreReturnCode:true,silent:true,input:Buffer.from(n),env:i}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){throw new Error(e.stderr.trim())}info("Login Succeeded!")}))}const Xh=process.env["STATE_registries"]?JSON.parse(process.env["STATE_registries"]):[];const Zh=/true/i.test(process.env["STATE_logout"]||"");function setRegistries(e){saveState("registries",JSON.stringify(e))}function setLogout(e){saveState("logout",e)}async function main(){const e=getInputs();setLogout(e.logout);const t=getAuthList(e);setRegistries(Array.from(new Map(t.map((e=>[`${e.registry}|${e.configDir}`,{registry:e.registry,configDir:e.configDir}]))).values()));if(t.length===1){await login(t[0]);return}for(const e of t){await group(`Login to ${e.registry}`,(async()=>{await login(e)}))}}async function post(){if(!Zh){return}for(const e of Xh){await group(`Logout from ${e.registry}`,(async()=>{await logout(e.registry,e.configDir)}))}}run(main,post);var ey=o.i;export{ey as main}; +/* v8 ignore else -- @preserve */var uh="0.0.0-development";function _buildMessageForResponseErrors(e){return`Request failed due to following response errors:\n`+e.errors.map((e=>` - ${e.message}`)).join("\n")}var dh=class extends Error{constructor(e,t,n){super(_buildMessageForResponseErrors(n));this.request=e;this.headers=t;this.response=n;this.errors=n.errors;this.data=n.data;if(Error.captureStackTrace){Error.captureStackTrace(this,this.constructor)}}name="GraphqlResponseError";errors;data};var ph=["method","baseUrl","url","headers","request","query","mediaType","operationName"];var Ah=["query","method","url"];var mh=/\/api\/v3\/?$/;function graphql(e,t,n){if(n){if(typeof t==="string"&&"query"in n){return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`))}for(const e in n){if(!Ah.includes(e))continue;return Promise.reject(new Error(`[@octokit/graphql] "${e}" cannot be used as variable name`))}}const o=typeof t==="string"?Object.assign({query:t},n):t;const i=Object.keys(o).reduce(((e,t)=>{if(ph.includes(t)){e[t]=o[t];return e}if(!e.variables){e.variables={}}e.variables[t]=o[t];return e}),{});const c=o.baseUrl||e.endpoint.DEFAULTS.baseUrl;if(mh.test(c)){i.url=c.replace(mh,"/api/graphql")}return e(i).then((e=>{if(e.data.errors){const t={};for(const n of Object.keys(e.headers)){t[n]=e.headers[n]}throw new dh(i,t,e.data)}return e.data.data}))}function graphql_dist_bundle_withDefaults(e,t){const n=e.defaults(t);const newApi=(e,t)=>graphql(n,e,t);return Object.assign(newApi,{defaults:graphql_dist_bundle_withDefaults.bind(null,n),endpoint:n.endpoint})}var gh=graphql_dist_bundle_withDefaults(lh,{headers:{"user-agent":`octokit-graphql.js/${uh} ${getUserAgent()}`},method:"POST",url:"/graphql"});function withCustomRequest(e){return graphql_dist_bundle_withDefaults(e,{method:"POST",url:"/graphql"})}var fh="(?:[a-zA-Z0-9_-]+)";var hh="\\.";var yh=new RegExp(`^${fh}${hh}${fh}${hh}${fh}$`);var Eh=yh.test.bind(yh);async function auth(e){const t=Eh(e);const n=e.startsWith("v1.")||e.startsWith("ghs_");const o=e.startsWith("ghu_");const i=t?"app":n?"installation":o?"user-to-server":"oauth";return{type:"token",token:e,tokenType:i}}function withAuthorizationPrefix(e){if(e.split(/\./).length===3){return`bearer ${e}`}return`token ${e}`}async function hook(e,t,n,o){const i=t.endpoint.merge(n,o);i.headers.authorization=withAuthorizationPrefix(e);return t(i)}var Ch=function createTokenAuth2(e){if(!e){throw new Error("[@octokit/auth-token] No token passed to createTokenAuth")}if(typeof e!=="string"){throw new Error("[@octokit/auth-token] Token passed to createTokenAuth is not a string")}e=e.replace(/^(token|bearer) +/i,"");return Object.assign(auth.bind(null,e),{hook:hook.bind(null,e)})};const Ih="7.0.6";const dist_src_noop=()=>{};const bh=console.warn.bind(console);const Sh=console.error.bind(console);function createLogger(e={}){if(typeof e.debug!=="function"){e.debug=dist_src_noop}if(typeof e.info!=="function"){e.info=dist_src_noop}if(typeof e.warn!=="function"){e.warn=bh}if(typeof e.error!=="function"){e.error=Sh}return e}const Bh=`octokit-core.js/${Ih} ${getUserAgent()}`;class Octokit{static VERSION=Ih;static defaults(e){const t=class extends(this){constructor(...t){const n=t[0]||{};if(typeof e==="function"){super(e(n));return}super(Object.assign({},e,n,n.userAgent&&e.userAgent?{userAgent:`${n.userAgent} ${e.userAgent}`}:null))}};return t}static plugins=[];static plugin(...e){const t=this.plugins;const n=class extends(this){static plugins=t.concat(e.filter((e=>!t.includes(e))))};return n}constructor(e={}){const t=new Gf.Collection;const n={baseUrl:lh.endpoint.DEFAULTS.baseUrl,headers:{},request:Object.assign({},e.request,{hook:t.bind(null,"request")}),mediaType:{previews:[],format:""}};n.headers["user-agent"]=e.userAgent?`${e.userAgent} ${Bh}`:Bh;if(e.baseUrl){n.baseUrl=e.baseUrl}if(e.previews){n.mediaType.previews=e.previews}if(e.timeZone){n.headers["time-zone"]=e.timeZone}this.request=lh.defaults(n);this.graphql=withCustomRequest(this.request).defaults(n);this.log=createLogger(e.log);this.hook=t;if(!e.authStrategy){if(!e.auth){this.auth=async()=>({type:"unauthenticated"})}else{const n=Ch(e.auth);t.wrap("request",n.hook);this.auth=n}}else{const{authStrategy:n,...o}=e;const i=n(Object.assign({request:this.request,log:this.log,octokit:this,octokitOptions:o},e.auth));t.wrap("request",i.hook);this.auth=i}const o=this.constructor;for(let t=0;t({async next(){if(!p)return{done:true};try{const e=await i({method:c,url:p,headers:d});const t=normalizePaginatedListResponse(e);p=((t.headers.link||"").match(/<([^<>]+)>;\s*rel="next"/)||[])[1];if(!p&&"total_commits"in t.data){const e=new URL(t.url);const n=e.searchParams;const o=parseInt(n.get("page")||"1",10);const i=parseInt(n.get("per_page")||"250",10);if(o*i{if(i.done){return t}let c=false;function done(){c=true}t=t.concat(o?o(i.value,done):i.value.data);if(c){return t}return gather(e,t,n,o)}))}var vh=Object.assign(paginate,{iterator:iterator});var Ph=null&&["GET /advisories","GET /app/hook/deliveries","GET /app/installation-requests","GET /app/installations","GET /assignments/{assignment_id}/accepted_assignments","GET /classrooms","GET /classrooms/{classroom_id}/assignments","GET /enterprises/{enterprise}/code-security/configurations","GET /enterprises/{enterprise}/code-security/configurations/{configuration_id}/repositories","GET /enterprises/{enterprise}/dependabot/alerts","GET /enterprises/{enterprise}/teams","GET /enterprises/{enterprise}/teams/{enterprise-team}/memberships","GET /enterprises/{enterprise}/teams/{enterprise-team}/organizations","GET /events","GET /gists","GET /gists/public","GET /gists/starred","GET /gists/{gist_id}/comments","GET /gists/{gist_id}/commits","GET /gists/{gist_id}/forks","GET /installation/repositories","GET /issues","GET /licenses","GET /marketplace_listing/plans","GET /marketplace_listing/plans/{plan_id}/accounts","GET /marketplace_listing/stubbed/plans","GET /marketplace_listing/stubbed/plans/{plan_id}/accounts","GET /networks/{owner}/{repo}/events","GET /notifications","GET /organizations","GET /organizations/{org}/dependabot/repository-access","GET /orgs/{org}/actions/cache/usage-by-repository","GET /orgs/{org}/actions/hosted-runners","GET /orgs/{org}/actions/permissions/repositories","GET /orgs/{org}/actions/permissions/self-hosted-runners/repositories","GET /orgs/{org}/actions/runner-groups","GET /orgs/{org}/actions/runner-groups/{runner_group_id}/hosted-runners","GET /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories","GET /orgs/{org}/actions/runner-groups/{runner_group_id}/runners","GET /orgs/{org}/actions/runners","GET /orgs/{org}/actions/secrets","GET /orgs/{org}/actions/secrets/{secret_name}/repositories","GET /orgs/{org}/actions/variables","GET /orgs/{org}/actions/variables/{name}/repositories","GET /orgs/{org}/attestations/repositories","GET /orgs/{org}/attestations/{subject_digest}","GET /orgs/{org}/blocks","GET /orgs/{org}/campaigns","GET /orgs/{org}/code-scanning/alerts","GET /orgs/{org}/code-security/configurations","GET /orgs/{org}/code-security/configurations/{configuration_id}/repositories","GET /orgs/{org}/codespaces","GET /orgs/{org}/codespaces/secrets","GET /orgs/{org}/codespaces/secrets/{secret_name}/repositories","GET /orgs/{org}/copilot/billing/seats","GET /orgs/{org}/copilot/metrics","GET /orgs/{org}/dependabot/alerts","GET /orgs/{org}/dependabot/secrets","GET /orgs/{org}/dependabot/secrets/{secret_name}/repositories","GET /orgs/{org}/events","GET /orgs/{org}/failed_invitations","GET /orgs/{org}/hooks","GET /orgs/{org}/hooks/{hook_id}/deliveries","GET /orgs/{org}/insights/api/route-stats/{actor_type}/{actor_id}","GET /orgs/{org}/insights/api/subject-stats","GET /orgs/{org}/insights/api/user-stats/{user_id}","GET /orgs/{org}/installations","GET /orgs/{org}/invitations","GET /orgs/{org}/invitations/{invitation_id}/teams","GET /orgs/{org}/issues","GET /orgs/{org}/members","GET /orgs/{org}/members/{username}/codespaces","GET /orgs/{org}/migrations","GET /orgs/{org}/migrations/{migration_id}/repositories","GET /orgs/{org}/organization-roles/{role_id}/teams","GET /orgs/{org}/organization-roles/{role_id}/users","GET /orgs/{org}/outside_collaborators","GET /orgs/{org}/packages","GET /orgs/{org}/packages/{package_type}/{package_name}/versions","GET /orgs/{org}/personal-access-token-requests","GET /orgs/{org}/personal-access-token-requests/{pat_request_id}/repositories","GET /orgs/{org}/personal-access-tokens","GET /orgs/{org}/personal-access-tokens/{pat_id}/repositories","GET /orgs/{org}/private-registries","GET /orgs/{org}/projects","GET /orgs/{org}/projectsV2","GET /orgs/{org}/projectsV2/{project_number}/fields","GET /orgs/{org}/projectsV2/{project_number}/items","GET /orgs/{org}/properties/values","GET /orgs/{org}/public_members","GET /orgs/{org}/repos","GET /orgs/{org}/rulesets","GET /orgs/{org}/rulesets/rule-suites","GET /orgs/{org}/rulesets/{ruleset_id}/history","GET /orgs/{org}/secret-scanning/alerts","GET /orgs/{org}/security-advisories","GET /orgs/{org}/settings/immutable-releases/repositories","GET /orgs/{org}/settings/network-configurations","GET /orgs/{org}/team/{team_slug}/copilot/metrics","GET /orgs/{org}/teams","GET /orgs/{org}/teams/{team_slug}/discussions","GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments","GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions","GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions","GET /orgs/{org}/teams/{team_slug}/invitations","GET /orgs/{org}/teams/{team_slug}/members","GET /orgs/{org}/teams/{team_slug}/projects","GET /orgs/{org}/teams/{team_slug}/repos","GET /orgs/{org}/teams/{team_slug}/teams","GET /projects/{project_id}/collaborators","GET /repos/{owner}/{repo}/actions/artifacts","GET /repos/{owner}/{repo}/actions/caches","GET /repos/{owner}/{repo}/actions/organization-secrets","GET /repos/{owner}/{repo}/actions/organization-variables","GET /repos/{owner}/{repo}/actions/runners","GET /repos/{owner}/{repo}/actions/runs","GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts","GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs","GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs","GET /repos/{owner}/{repo}/actions/secrets","GET /repos/{owner}/{repo}/actions/variables","GET /repos/{owner}/{repo}/actions/workflows","GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs","GET /repos/{owner}/{repo}/activity","GET /repos/{owner}/{repo}/assignees","GET /repos/{owner}/{repo}/attestations/{subject_digest}","GET /repos/{owner}/{repo}/branches","GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations","GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs","GET /repos/{owner}/{repo}/code-scanning/alerts","GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances","GET /repos/{owner}/{repo}/code-scanning/analyses","GET /repos/{owner}/{repo}/codespaces","GET /repos/{owner}/{repo}/codespaces/devcontainers","GET /repos/{owner}/{repo}/codespaces/secrets","GET /repos/{owner}/{repo}/collaborators","GET /repos/{owner}/{repo}/comments","GET /repos/{owner}/{repo}/comments/{comment_id}/reactions","GET /repos/{owner}/{repo}/commits","GET /repos/{owner}/{repo}/commits/{commit_sha}/comments","GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls","GET /repos/{owner}/{repo}/commits/{ref}/check-runs","GET /repos/{owner}/{repo}/commits/{ref}/check-suites","GET /repos/{owner}/{repo}/commits/{ref}/status","GET /repos/{owner}/{repo}/commits/{ref}/statuses","GET /repos/{owner}/{repo}/compare/{basehead}","GET /repos/{owner}/{repo}/compare/{base}...{head}","GET /repos/{owner}/{repo}/contributors","GET /repos/{owner}/{repo}/dependabot/alerts","GET /repos/{owner}/{repo}/dependabot/secrets","GET /repos/{owner}/{repo}/deployments","GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses","GET /repos/{owner}/{repo}/environments","GET /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies","GET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/apps","GET /repos/{owner}/{repo}/environments/{environment_name}/secrets","GET /repos/{owner}/{repo}/environments/{environment_name}/variables","GET /repos/{owner}/{repo}/events","GET /repos/{owner}/{repo}/forks","GET /repos/{owner}/{repo}/hooks","GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries","GET /repos/{owner}/{repo}/invitations","GET /repos/{owner}/{repo}/issues","GET /repos/{owner}/{repo}/issues/comments","GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions","GET /repos/{owner}/{repo}/issues/events","GET /repos/{owner}/{repo}/issues/{issue_number}/comments","GET /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by","GET /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocking","GET /repos/{owner}/{repo}/issues/{issue_number}/events","GET /repos/{owner}/{repo}/issues/{issue_number}/labels","GET /repos/{owner}/{repo}/issues/{issue_number}/reactions","GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issues","GET /repos/{owner}/{repo}/issues/{issue_number}/timeline","GET /repos/{owner}/{repo}/keys","GET /repos/{owner}/{repo}/labels","GET /repos/{owner}/{repo}/milestones","GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels","GET /repos/{owner}/{repo}/notifications","GET /repos/{owner}/{repo}/pages/builds","GET /repos/{owner}/{repo}/projects","GET /repos/{owner}/{repo}/pulls","GET /repos/{owner}/{repo}/pulls/comments","GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions","GET /repos/{owner}/{repo}/pulls/{pull_number}/comments","GET /repos/{owner}/{repo}/pulls/{pull_number}/commits","GET /repos/{owner}/{repo}/pulls/{pull_number}/files","GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews","GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments","GET /repos/{owner}/{repo}/releases","GET /repos/{owner}/{repo}/releases/{release_id}/assets","GET /repos/{owner}/{repo}/releases/{release_id}/reactions","GET /repos/{owner}/{repo}/rules/branches/{branch}","GET /repos/{owner}/{repo}/rulesets","GET /repos/{owner}/{repo}/rulesets/rule-suites","GET /repos/{owner}/{repo}/rulesets/{ruleset_id}/history","GET /repos/{owner}/{repo}/secret-scanning/alerts","GET /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}/locations","GET /repos/{owner}/{repo}/security-advisories","GET /repos/{owner}/{repo}/stargazers","GET /repos/{owner}/{repo}/subscribers","GET /repos/{owner}/{repo}/tags","GET /repos/{owner}/{repo}/teams","GET /repos/{owner}/{repo}/topics","GET /repositories","GET /search/code","GET /search/commits","GET /search/issues","GET /search/labels","GET /search/repositories","GET /search/topics","GET /search/users","GET /teams/{team_id}/discussions","GET /teams/{team_id}/discussions/{discussion_number}/comments","GET /teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}/reactions","GET /teams/{team_id}/discussions/{discussion_number}/reactions","GET /teams/{team_id}/invitations","GET /teams/{team_id}/members","GET /teams/{team_id}/projects","GET /teams/{team_id}/repos","GET /teams/{team_id}/teams","GET /user/blocks","GET /user/codespaces","GET /user/codespaces/secrets","GET /user/emails","GET /user/followers","GET /user/following","GET /user/gpg_keys","GET /user/installations","GET /user/installations/{installation_id}/repositories","GET /user/issues","GET /user/keys","GET /user/marketplace_purchases","GET /user/marketplace_purchases/stubbed","GET /user/memberships/orgs","GET /user/migrations","GET /user/migrations/{migration_id}/repositories","GET /user/orgs","GET /user/packages","GET /user/packages/{package_type}/{package_name}/versions","GET /user/public_emails","GET /user/repos","GET /user/repository_invitations","GET /user/social_accounts","GET /user/ssh_signing_keys","GET /user/starred","GET /user/subscriptions","GET /user/teams","GET /users","GET /users/{username}/attestations/{subject_digest}","GET /users/{username}/events","GET /users/{username}/events/orgs/{org}","GET /users/{username}/events/public","GET /users/{username}/followers","GET /users/{username}/following","GET /users/{username}/gists","GET /users/{username}/gpg_keys","GET /users/{username}/keys","GET /users/{username}/orgs","GET /users/{username}/packages","GET /users/{username}/projects","GET /users/{username}/projectsV2","GET /users/{username}/projectsV2/{project_number}/fields","GET /users/{username}/projectsV2/{project_number}/items","GET /users/{username}/received_events","GET /users/{username}/received_events/public","GET /users/{username}/repos","GET /users/{username}/social_accounts","GET /users/{username}/ssh_signing_keys","GET /users/{username}/starred","GET /users/{username}/subscriptions"];function isPaginatingEndpoint(e){if(typeof e==="string"){return Ph.includes(e)}else{return false}}function paginateRest(e){return{paginate:Object.assign(paginate.bind(null,e),{iterator:iterator.bind(null,e)})}}paginateRest.VERSION=Th;const Dh=new Context;const kh=getApiBaseUrl();const _h={baseUrl:kh,request:{agent:getProxyAgent(kh),fetch:getProxyFetch(kh)}};const Lh=Octokit.plugin(restEndpointMethods,paginateRest).defaults(_h);function getOctokitOptions(e,t){const n=Object.assign({},t||{});const o=getAuthString(e,n);if(o){n.auth=o}return n}const Oh=new Context;function getOctokit(e,t,...n){const o=Lh.plugin(...n);return new o(getOctokitOptions(e,t))}class InvalidTokenError extends Error{}InvalidTokenError.prototype.name="InvalidTokenError";function b64DecodeUnicode(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();if(n.length<2){n="0"+n}return"%"+n})))}function base64UrlDecode(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return b64DecodeUnicode(t)}catch(e){return atob(t)}}function jwtDecode(e,t){if(typeof e!=="string"){throw new InvalidTokenError("Invalid token specified: must be a string")}t||(t={});const n=t.header===true?0:1;const o=e.split(".")[n];if(typeof o!=="string"){throw new InvalidTokenError(`Invalid token specified: missing part #${n+1}`)}let i;try{i=base64UrlDecode(o)}catch(e){throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(i)}catch(e){throw new InvalidTokenError(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}class github_GitHub{githubToken;octokit;constructor(e){this.githubToken=e?.token||process.env.GITHUB_TOKEN;this.octokit=getOctokit(`${this.githubToken}`)}repoData(){return this.octokit.rest.repos.get({...Oh.repo}).then((e=>e.data))}async releases(e,t){let n;try{n=await this.releasesRaw(e,t)}catch(o){if(!this.githubToken){throw o}n=await this.releasesRaw(e,t,this.githubToken)}return n}async releasesRaw(e,t,n){const o=`https://raw.githubusercontent.com/${t.owner}/${t.repo}/${t.ref}/${t.path}`;const i=new lib_HttpClient("docker-actions-toolkit");const c=await i.get(o,n?{Authorization:`token ${n}`}:undefined);const d=await c.readBody();const p=c.message.statusCode||500;if(p>=400){throw new Error(`Failed to get ${e} releases from ${o} with status code ${p}: ${d}`)}return JSON.parse(d)}static get context(){return Oh}static get serverURL(){return process.env.GITHUB_SERVER_URL||"https://github.com"}static get apiURL(){return process.env.GITHUB_API_URL||"https://api.github.com"}static get isGHES(){const e=new URL(github_GitHub.serverURL);const t=e.hostname.trimEnd().toUpperCase();const n=t==="GITHUB.COM";const o=t.endsWith(".GHE.COM");const i=t.endsWith(".LOCALHOST");return!n&&!o&&!i}static get repository(){return`${Oh.repo.owner}/${Oh.repo.repo}`}static get workspace(){return process.env.GITHUB_WORKSPACE||process.cwd()}static get runId(){return process.env.GITHUB_RUN_ID?+process.env.GITHUB_RUN_ID:Oh.runId}static get runAttempt(){return process.env.GITHUB_RUN_ATTEMPT?+process.env.GITHUB_RUN_ATTEMPT:1}static workflowRunURL(e){return`${github_GitHub.serverURL}/${github_GitHub.repository}/actions/runs/${github_GitHub.runId}${e?`/attempts/${github_GitHub.runAttempt}`:""}`}static get actionsRuntimeToken(){const e=process.env["ACTIONS_RUNTIME_TOKEN"]||"";return e?jwtDecode(e):undefined}static async printActionsRuntimeTokenACs(){let e;try{e=github_GitHub.actionsRuntimeToken}catch(e){throw new Error(`Cannot parse GitHub Actions Runtime Token: ${e.message}`)}if(!e){throw new Error(`ACTIONS_RUNTIME_TOKEN not set`)}try{JSON.parse(`${e.ac}`).forEach((e=>{let t;switch(e.Permission){case 1:t="read";break;case 2:t="write";break;case 3:t="read/write";break;default:t=`unimplemented (${e.Permission})`}info(`${e.Scope}: ${t}`)}))}catch(e){throw new Error(`Cannot parse GitHub Actions Runtime Token ACs: ${e.message}`)}}}class context_Context{static _tmpDir=y.mkdtempSync(C.join(context_Context.ensureDirExists(process.env.RUNNER_TEMP||c.tmpdir()),"docker-actions-toolkit-"));static ensureDirExists(e){y.mkdirSync(e,{recursive:true});return e}static tmpDir(){return context_Context._tmpDir}static tmpName(e){return Ff.om(e)}static gitRef(){return context_Context.parseGitRef(Oh.ref,Oh.sha)}static parseGitRef(e,t){const n=!!(process.env.DOCKER_DEFAULT_GIT_CONTEXT_PR_HEAD_REF&&process.env.DOCKER_DEFAULT_GIT_CONTEXT_PR_HEAD_REF==="true");if(t&&e&&!e.startsWith("refs/")){e=`refs/heads/${e}`}if(t&&!e.startsWith(`refs/pull/`)){e=t}else if(e.startsWith(`refs/pull/`)&&n){e=e.replace(/\/merge$/g,"/head")}return e}static gitContext(){return`${github_GitHub.serverURL}/${Oh.repo.owner}/${Oh.repo.repo}.git#${context_Context.gitRef()}`}}class Exec{static async exec(e,t,n){core_debug(`Exec.exec: ${e} ${t?.join(" ")}`);return exec_exec(e,t,n)}static async getExecOutput(e,t,n){core_debug(`Exec.getExecOutput: ${e} ${t?.join(" ")}`);return getExecOutput(e,t,n)}}class CsvError extends Error{constructor(e,t,n,...o){if(Array.isArray(t))t=t.join(" ").trim();super(t);if(Error.captureStackTrace!==undefined){Error.captureStackTrace(this,CsvError)}this.code=e;for(const e of o){for(const t in e){const o=e[t];this[t]=Buffer.isBuffer(o)?o.toString(n.encoding):o==null?o:JSON.parse(JSON.stringify(o))}}}}const is_object=function(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)};const normalize_columns_array=function(e){const t=[];for(let n=0,o=e.length;n=this.size){this.resize();if(t>=this.size){throw Error("INVALID_BUFFER_STATE")}}const n=this.buf;this.buf=Buffer.allocUnsafe(this.size);e.copy(this.buf,0);n.copy(this.buf,e.length);this.length+=e.length}else{const t=this.length++;if(t===this.size){this.resize()}const n=this.clone();this.buf[0]=e;n.copy(this.buf,1,0,t)}}append(e){const t=this.length++;if(t===this.size){this.resize()}this.buf[t]=e}clone(){return Buffer.from(this.buf.slice(0,this.length))}resize(){const e=this.length;this.size=this.size*2;const t=Buffer.allocUnsafe(this.size);this.buf.copy(t,0,0,e);this.buf=t}toString(e){if(e){return this.buf.slice(0,this.length).toString(e)}else{return Uint8Array.prototype.slice.call(this.buf.slice(0,this.length))}}toJSON(){return this.toString("utf8")}reset(){this.length=0}}const Fh=ResizeableBuffer;const Uh=12;const Mh=13;const Hh=10;const $h=32;const Gh=9;const init_state=function(e){return{bomSkipped:false,bufBytesStart:0,castField:e.cast_function,commenting:false,error:undefined,enabled:e.from_line===1,escaping:false,escapeIsQuote:Buffer.isBuffer(e.escape)&&Buffer.isBuffer(e.quote)&&Buffer.compare(e.escape,e.quote)===0,expectedRecordLength:Array.isArray(e.columns)?e.columns.length:undefined,field:new Fh(20),firstLineToHeaders:e.cast_first_line_to_header,needMoreDataSize:Math.max(e.comment!==null?e.comment.length:0,...e.delimiter.map((e=>e.length)),e.quote!==null?e.quote.length:0),previousBuf:undefined,quoting:false,stop:false,rawBuffer:new Fh(100),record:[],recordHasError:false,record_length:0,recordDelimiterMaxLength:e.record_delimiter.length===0?0:Math.max(...e.record_delimiter.map((e=>e.length))),trimChars:[Buffer.from(" ",e.encoding)[0],Buffer.from("\t",e.encoding)[0]],wasQuoting:false,wasRowDelimiter:false,timchars:[Buffer.from(Buffer.from([Mh],"utf8").toString(),e.encoding),Buffer.from(Buffer.from([Hh],"utf8").toString(),e.encoding),Buffer.from(Buffer.from([Uh],"utf8").toString(),e.encoding),Buffer.from(Buffer.from([$h],"utf8").toString(),e.encoding),Buffer.from(Buffer.from([Gh],"utf8").toString(),e.encoding)]}};const underscore=function(e){return e.replace(/([A-Z])/g,(function(e,t){return"_"+t.toLowerCase()}))};const normalize_options=function(e){const t={};for(const n in e){t[underscore(n)]=e[n]}if(t.encoding===undefined||t.encoding===true){t.encoding="utf8"}else if(t.encoding===null||t.encoding===false){t.encoding=null}else if(typeof t.encoding!=="string"&&t.encoding!==null){throw new CsvError("CSV_INVALID_OPTION_ENCODING",["Invalid option encoding:","encoding must be a string or null to return a buffer,",`got ${JSON.stringify(t.encoding)}`],t)}if(t.bom===undefined||t.bom===null||t.bom===false){t.bom=false}else if(t.bom!==true){throw new CsvError("CSV_INVALID_OPTION_BOM",["Invalid option bom:","bom must be true,",`got ${JSON.stringify(t.bom)}`],t)}t.cast_function=null;if(t.cast===undefined||t.cast===null||t.cast===false||t.cast===""){t.cast=undefined}else if(typeof t.cast==="function"){t.cast_function=t.cast;t.cast=true}else if(t.cast!==true){throw new CsvError("CSV_INVALID_OPTION_CAST",["Invalid option cast:","cast must be true or a function,",`got ${JSON.stringify(t.cast)}`],t)}if(t.cast_date===undefined||t.cast_date===null||t.cast_date===false||t.cast_date===""){t.cast_date=false}else if(t.cast_date===true){t.cast_date=function(e){const t=Date.parse(e);return!isNaN(t)?new Date(t):e}}else if(typeof t.cast_date!=="function"){throw new CsvError("CSV_INVALID_OPTION_CAST_DATE",["Invalid option cast_date:","cast_date must be true or a function,",`got ${JSON.stringify(t.cast_date)}`],t)}t.cast_first_line_to_header=undefined;if(t.columns===true){t.cast_first_line_to_header=undefined}else if(typeof t.columns==="function"){t.cast_first_line_to_header=t.columns;t.columns=true}else if(Array.isArray(t.columns)){t.columns=normalize_columns_array(t.columns)}else if(t.columns===undefined||t.columns===null||t.columns===false){t.columns=false}else{throw new CsvError("CSV_INVALID_OPTION_COLUMNS",["Invalid option columns:","expect an array, a function or true,",`got ${JSON.stringify(t.columns)}`],t)}if(t.group_columns_by_name===undefined||t.group_columns_by_name===null||t.group_columns_by_name===false){t.group_columns_by_name=false}else if(t.group_columns_by_name!==true){throw new CsvError("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","expect an boolean,",`got ${JSON.stringify(t.group_columns_by_name)}`],t)}else if(t.columns===false){throw new CsvError("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","the `columns` mode must be activated."],t)}if(t.comment===undefined||t.comment===null||t.comment===false||t.comment===""){t.comment=null}else{if(typeof t.comment==="string"){t.comment=Buffer.from(t.comment,t.encoding)}if(!Buffer.isBuffer(t.comment)){throw new CsvError("CSV_INVALID_OPTION_COMMENT",["Invalid option comment:","comment must be a buffer or a string,",`got ${JSON.stringify(t.comment)}`],t)}}if(t.comment_no_infix===undefined||t.comment_no_infix===null||t.comment_no_infix===false){t.comment_no_infix=false}else if(t.comment_no_infix!==true){throw new CsvError("CSV_INVALID_OPTION_COMMENT",["Invalid option comment_no_infix:","value must be a boolean,",`got ${JSON.stringify(t.comment_no_infix)}`],t)}const n=JSON.stringify(t.delimiter);if(!Array.isArray(t.delimiter))t.delimiter=[t.delimiter];if(t.delimiter.length===0){throw new CsvError("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${n}`],t)}t.delimiter=t.delimiter.map((function(e){if(e===undefined||e===null||e===false){return Buffer.from(",",t.encoding)}if(typeof e==="string"){e=Buffer.from(e,t.encoding)}if(!Buffer.isBuffer(e)||e.length===0){throw new CsvError("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${n}`],t)}return e}));if(t.escape===undefined||t.escape===true){t.escape=Buffer.from('"',t.encoding)}else if(typeof t.escape==="string"){t.escape=Buffer.from(t.escape,t.encoding)}else if(t.escape===null||t.escape===false){t.escape=null}if(t.escape!==null){if(!Buffer.isBuffer(t.escape)){throw new Error(`Invalid Option: escape must be a buffer, a string or a boolean, got ${JSON.stringify(t.escape)}`)}}if(t.from===undefined||t.from===null){t.from=1}else{if(typeof t.from==="string"&&/\d+/.test(t.from)){t.from=parseInt(t.from)}if(Number.isInteger(t.from)){if(t.from<0){throw new Error(`Invalid Option: from must be a positive integer, got ${JSON.stringify(e.from)}`)}}else{throw new Error(`Invalid Option: from must be an integer, got ${JSON.stringify(t.from)}`)}}if(t.from_line===undefined||t.from_line===null){t.from_line=1}else{if(typeof t.from_line==="string"&&/\d+/.test(t.from_line)){t.from_line=parseInt(t.from_line)}if(Number.isInteger(t.from_line)){if(t.from_line<=0){throw new Error(`Invalid Option: from_line must be a positive integer greater than 0, got ${JSON.stringify(e.from_line)}`)}}else{throw new Error(`Invalid Option: from_line must be an integer, got ${JSON.stringify(e.from_line)}`)}}if(t.ignore_last_delimiters===undefined||t.ignore_last_delimiters===null){t.ignore_last_delimiters=false}else if(typeof t.ignore_last_delimiters==="number"){t.ignore_last_delimiters=Math.floor(t.ignore_last_delimiters);if(t.ignore_last_delimiters===0){t.ignore_last_delimiters=false}}else if(typeof t.ignore_last_delimiters!=="boolean"){throw new CsvError("CSV_INVALID_OPTION_IGNORE_LAST_DELIMITERS",["Invalid option `ignore_last_delimiters`:","the value must be a boolean value or an integer,",`got ${JSON.stringify(t.ignore_last_delimiters)}`],t)}if(t.ignore_last_delimiters===true&&t.columns===false){throw new CsvError("CSV_IGNORE_LAST_DELIMITERS_REQUIRES_COLUMNS",["The option `ignore_last_delimiters`","requires the activation of the `columns` option"],t)}if(t.info===undefined||t.info===null||t.info===false){t.info=false}else if(t.info!==true){throw new Error(`Invalid Option: info must be true, got ${JSON.stringify(t.info)}`)}if(t.max_record_size===undefined||t.max_record_size===null||t.max_record_size===false){t.max_record_size=0}else if(Number.isInteger(t.max_record_size)&&t.max_record_size>=0){}else if(typeof t.max_record_size==="string"&&/\d+/.test(t.max_record_size)){t.max_record_size=parseInt(t.max_record_size)}else{throw new Error(`Invalid Option: max_record_size must be a positive integer, got ${JSON.stringify(t.max_record_size)}`)}if(t.objname===undefined||t.objname===null||t.objname===false){t.objname=undefined}else if(Buffer.isBuffer(t.objname)){if(t.objname.length===0){throw new Error(`Invalid Option: objname must be a non empty buffer`)}if(t.encoding===null){}else{t.objname=t.objname.toString(t.encoding)}}else if(typeof t.objname==="string"){if(t.objname.length===0){throw new Error(`Invalid Option: objname must be a non empty string`)}}else if(typeof t.objname==="number"){}else{throw new Error(`Invalid Option: objname must be a string or a buffer, got ${t.objname}`)}if(t.objname!==undefined){if(typeof t.objname==="number"){if(t.columns!==false){throw Error("Invalid Option: objname index cannot be combined with columns or be defined as a field")}}else{if(t.columns===false){throw Error("Invalid Option: objname field must be combined with columns or be defined as an index")}}}if(t.on_record===undefined||t.on_record===null){t.on_record=undefined}else if(typeof t.on_record!=="function"){throw new CsvError("CSV_INVALID_OPTION_ON_RECORD",["Invalid option `on_record`:","expect a function,",`got ${JSON.stringify(t.on_record)}`],t)}if(t.on_skip!==undefined&&t.on_skip!==null&&typeof t.on_skip!=="function"){throw new Error(`Invalid Option: on_skip must be a function, got ${JSON.stringify(t.on_skip)}`)}if(t.quote===null||t.quote===false||t.quote===""){t.quote=null}else{if(t.quote===undefined||t.quote===true){t.quote=Buffer.from('"',t.encoding)}else if(typeof t.quote==="string"){t.quote=Buffer.from(t.quote,t.encoding)}if(!Buffer.isBuffer(t.quote)){throw new Error(`Invalid Option: quote must be a buffer or a string, got ${JSON.stringify(t.quote)}`)}}if(t.raw===undefined||t.raw===null||t.raw===false){t.raw=false}else if(t.raw!==true){throw new Error(`Invalid Option: raw must be true, got ${JSON.stringify(t.raw)}`)}if(t.record_delimiter===undefined){t.record_delimiter=[]}else if(typeof t.record_delimiter==="string"||Buffer.isBuffer(t.record_delimiter)){if(t.record_delimiter.length===0){throw new CsvError("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer,",`got ${JSON.stringify(t.record_delimiter)}`],t)}t.record_delimiter=[t.record_delimiter]}else if(!Array.isArray(t.record_delimiter)){throw new CsvError("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer,",`got ${JSON.stringify(t.record_delimiter)}`],t)}t.record_delimiter=t.record_delimiter.map((function(e,n){if(typeof e!=="string"&&!Buffer.isBuffer(e)){throw new CsvError("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer",`at index ${n},`,`got ${JSON.stringify(e)}`],t)}else if(e.length===0){throw new CsvError("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer",`at index ${n},`,`got ${JSON.stringify(e)}`],t)}if(typeof e==="string"){e=Buffer.from(e,t.encoding)}return e}));if(typeof t.relax_column_count==="boolean"){}else if(t.relax_column_count===undefined||t.relax_column_count===null){t.relax_column_count=false}else{throw new Error(`Invalid Option: relax_column_count must be a boolean, got ${JSON.stringify(t.relax_column_count)}`)}if(typeof t.relax_column_count_less==="boolean"){}else if(t.relax_column_count_less===undefined||t.relax_column_count_less===null){t.relax_column_count_less=false}else{throw new Error(`Invalid Option: relax_column_count_less must be a boolean, got ${JSON.stringify(t.relax_column_count_less)}`)}if(typeof t.relax_column_count_more==="boolean"){}else if(t.relax_column_count_more===undefined||t.relax_column_count_more===null){t.relax_column_count_more=false}else{throw new Error(`Invalid Option: relax_column_count_more must be a boolean, got ${JSON.stringify(t.relax_column_count_more)}`)}if(typeof t.relax_quotes==="boolean"){}else if(t.relax_quotes===undefined||t.relax_quotes===null){t.relax_quotes=false}else{throw new Error(`Invalid Option: relax_quotes must be a boolean, got ${JSON.stringify(t.relax_quotes)}`)}if(typeof t.skip_empty_lines==="boolean"){}else if(t.skip_empty_lines===undefined||t.skip_empty_lines===null){t.skip_empty_lines=false}else{throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(t.skip_empty_lines)}`)}if(typeof t.skip_records_with_empty_values==="boolean"){}else if(t.skip_records_with_empty_values===undefined||t.skip_records_with_empty_values===null){t.skip_records_with_empty_values=false}else{throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(t.skip_records_with_empty_values)}`)}if(typeof t.skip_records_with_error==="boolean"){}else if(t.skip_records_with_error===undefined||t.skip_records_with_error===null){t.skip_records_with_error=false}else{throw new Error(`Invalid Option: skip_records_with_error must be a boolean, got ${JSON.stringify(t.skip_records_with_error)}`)}if(t.rtrim===undefined||t.rtrim===null||t.rtrim===false){t.rtrim=false}else if(t.rtrim!==true){throw new Error(`Invalid Option: rtrim must be a boolean, got ${JSON.stringify(t.rtrim)}`)}if(t.ltrim===undefined||t.ltrim===null||t.ltrim===false){t.ltrim=false}else if(t.ltrim!==true){throw new Error(`Invalid Option: ltrim must be a boolean, got ${JSON.stringify(t.ltrim)}`)}if(t.trim===undefined||t.trim===null||t.trim===false){t.trim=false}else if(t.trim!==true){throw new Error(`Invalid Option: trim must be a boolean, got ${JSON.stringify(t.trim)}`)}if(t.trim===true&&e.ltrim!==false){t.ltrim=true}else if(t.ltrim!==true){t.ltrim=false}if(t.trim===true&&e.rtrim!==false){t.rtrim=true}else if(t.rtrim!==true){t.rtrim=false}if(t.to===undefined||t.to===null){t.to=-1}else if(t.to!==-1){if(typeof t.to==="string"&&/\d+/.test(t.to)){t.to=parseInt(t.to)}if(Number.isInteger(t.to)){if(t.to<=0){throw new Error(`Invalid Option: to must be a positive integer greater than 0, got ${JSON.stringify(e.to)}`)}}else{throw new Error(`Invalid Option: to must be an integer, got ${JSON.stringify(e.to)}`)}}if(t.to_line===undefined||t.to_line===null){t.to_line=-1}else if(t.to_line!==-1){if(typeof t.to_line==="string"&&/\d+/.test(t.to_line)){t.to_line=parseInt(t.to_line)}if(Number.isInteger(t.to_line)){if(t.to_line<=0){throw new Error(`Invalid Option: to_line must be a positive integer greater than 0, got ${JSON.stringify(e.to_line)}`)}}else{throw new Error(`Invalid Option: to_line must be an integer, got ${JSON.stringify(e.to_line)}`)}}return t};const isRecordEmpty=function(e){return e.every((e=>e==null||e.toString&&e.toString().trim()===""))};const qh=13;const zh=10;const Vh={utf8:Buffer.from([239,187,191]),utf16le:Buffer.from([255,254])};const transform=function(e={}){const t={bytes:0,comment_lines:0,empty_lines:0,invalid_field_length:0,lines:1,records:0};const n=normalize_options(e);return{info:t,original_options:e,options:n,state:init_state(n),__needMoreData:function(e,t,n){if(n)return false;const{encoding:o,escape:i,quote:c}=this.options;const{quoting:d,needMoreDataSize:p,recordDelimiterMaxLength:y}=this.state;const C=t-e-1;const Q=Math.max(p,y===0?Buffer.from("\r\n",o).length:y,d?(i===null?0:i.length)+c.length:0,d?c.length+y:0);return CV){this.state.stop=true;o();return}if(this.state.quoting===false&&ne.length===0){const e=this.__autoDiscoverRecordDelimiter(ce,ue);if(e){ne=this.options.record_delimiter}}const e=ce[ue];if(Q===true){ie.append(e)}if((e===qh||e===zh)&&this.state.wasRowDelimiter===false){this.state.wasRowDelimiter=true}if(this.state.escaping===true){this.state.escaping=false}else{if(te!==null&&this.state.quoting===true&&this.__isEscape(ce,ue,e)&&ue+te.lengthVh[e].equals(this.state.field.toString())?e:false)).filter(Boolean)[0];const n=this.__error(new CsvError("INVALID_OPENING_QUOTE",["Invalid Opening Quote:",`a quote is found on field ${JSON.stringify(e.column)} at line ${e.lines}, value is ${JSON.stringify(this.state.field.toString(d))}`,t?`(${t} bom)`:undefined],this.options,e,{field:this.state.field}));if(n!==undefined)return n}}else{this.state.quoting=true;ue+=re.length-1;continue}}}if(this.state.quoting===false){const t=this.__isRecordDelimiter(e,ce,ue);if(t!==0){const e=this.state.commenting&&this.state.wasQuoting===false&&this.state.record.length===0&&this.state.field.length===0;if(e){this.info.comment_lines++}else{if(this.state.enabled===false&&this.info.lines+(this.state.wasRowDelimiter===true?1:0)>=p){this.state.enabled=true;this.__resetField();this.__resetRecord();ue+=t-1;continue}if(k===true&&this.state.wasQuoting===false&&this.state.record.length===0&&this.state.field.length===0){this.info.empty_lines++;ue+=t-1;continue}this.info.bytes=this.state.bufBytesStart+ue;const e=this.__onField();if(e!==undefined)return e;this.info.bytes=this.state.bufBytesStart+ue+t;const i=this.__onRecord(n);if(i!==undefined)return i;if($!==-1&&this.info.records>=$){this.state.stop=true;o();return}}this.state.commenting=false;ue+=t-1;continue}if(this.state.commenting){continue}if(ee!==null&&(c===false||this.state.record.length===0&&this.state.field.length===0)){const t=this.__compareBytes(ee,ce,ue,e);if(t!==0){this.state.commenting=true;continue}}const i=this.__isDelimiter(ce,ue,e);if(i!==0){this.info.bytes=this.state.bufBytesStart+ue;const e=this.__onField();if(e!==undefined)return e;ue+=i-1;continue}}}if(this.state.commenting===false){if(C!==0&&this.state.record_length+this.state.field.length>C){return this.__error(new CsvError("CSV_MAX_RECORD_SIZE",["Max Record Size:","record exceed the maximum number of tolerated bytes",`of ${C}`,`at line ${this.info.lines}`],this.options,this.__infoField()))}}const i=y===false||this.state.quoting===true||this.state.field.length!==0||!this.__isCharTrimable(ce,ue);const se=D===false||this.state.wasQuoting===false;if(i===true&&se===true){this.state.field.append(e)}else if(D===true&&!this.__isCharTrimable(ce,ue)){return this.__error(new CsvError("CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE",["Invalid Closing Quote:","found non trimable byte after quote",`at line ${this.info.lines}`],this.options,this.__infoField()))}else{if(i===false){ue+=this.__isCharTrimable(ce,ue)-1}continue}}if(t===true){if(this.state.quoting===true){const e=this.__error(new CsvError("CSV_QUOTE_NOT_CLOSED",["Quote Not Closed:",`the parsing is finished with an opening quote at line ${this.info.lines}`],this.options,this.__infoField()));if(e!==undefined)return e}else{if(this.state.wasQuoting===true||this.state.record.length!==0||this.state.field.length!==0){this.info.bytes=this.state.bufBytesStart+ue;const e=this.__onField();if(e!==undefined)return e;const t=this.__onRecord(n);if(t!==undefined)return t}else if(this.state.wasRowDelimiter===true){this.info.empty_lines++}else if(this.state.commenting===true){this.info.comment_lines++}}}else{this.state.bufBytesStart+=ue;this.state.previousBuf=ce.slice(ue)}if(this.state.wasRowDelimiter===true){this.info.lines++;this.state.wasRowDelimiter=false}},__onRecord:function(e){const{columns:t,group_columns_by_name:n,encoding:o,info:i,from:c,relax_column_count:d,relax_column_count_less:p,relax_column_count_more:y,raw:C,skip_records_with_empty_values:Q}=this.options;const{enabled:v,record:D}=this.state;if(v===false){return this.__resetRecord()}const k=D.length;if(t===true){if(Q===true&&isRecordEmpty(D)){this.__resetRecord();return}return this.__firstLineToColumns(D)}if(t===false&&this.info.records===0){this.state.expectedRecordLength=k}if(k!==this.state.expectedRecordLength){const e=t===false?new CsvError("CSV_RECORD_INCONSISTENT_FIELDS_LENGTH",["Invalid Record Length:",`expect ${this.state.expectedRecordLength},`,`got ${k} on line ${this.info.lines}`],this.options,this.__infoField(),{record:D}):new CsvError("CSV_RECORD_INCONSISTENT_COLUMNS",["Invalid Record Length:",`columns length is ${t.length},`,`got ${k} on line ${this.info.lines}`],this.options,this.__infoField(),{record:D});if(d===true||p===true&&kthis.state.expectedRecordLength){this.info.invalid_field_length++;this.state.error=e}else{const t=this.__error(e);if(t)return t}}if(Q===true&&isRecordEmpty(D)){this.__resetRecord();return}if(this.state.recordHasError===true){this.__resetRecord();this.state.recordHasError=false;return}this.info.records++;if(c===1||this.info.records>=c){const{objname:c}=this.options;if(t!==false){const d={};for(let e=0,o=D.length;e{const{timchars:n}=this.state;e:for(let o=0;o=0},__compareBytes:function(e,t,n,o){if(e[0]!==o)return 0;const i=e.length;for(let o=1;othis.state.record.length?e[this.state.record.length].name:null:this.state.record.length,quoting:this.state.wasQuoting}}}};const sync_parse=function(e,t={}){if(typeof e==="string"){e=Buffer.from(e)}const n=t&&t.objname?{}:[];const o=transform(t);const push=e=>{if(o.options.objname===undefined)n.push(e);else{n[e[0]]=e[1]}};const close=()=>{};const i=o.parse(e,true,push,close);if(i!==undefined)throw i;return n};class Util{static getInputList(e,t){return this.getList(getInput(e),t)}static getList(e,t){const n=[];if(e==""){return n}const o=sync_parse(e,{columns:false,relaxQuotes:true,comment:t?.comment,comment_no_infix:t?.commentNoInfix,relaxColumnCount:true,skipEmptyLines:true,quote:t?.quote});for(const e of o){if(e.length==1){if(t?.ignoreComma){n.push(e[0])}else{n.push(...e[0].split(","))}}else if(!t?.ignoreComma){n.push(...e)}else{n.push(e.join(","))}}return n.filter((e=>e)).map((e=>e.trim()))}static getInputNumber(e){const t=getInput(e);if(!t){return undefined}return parseInt(t)}static async asyncForEach(e,t){for(let n=0;nsetTimeout(t,e*1e3)))}static hash(e){return p.createHash("sha256").update(e).digest("hex")}static parseBool(e){switch(e){case"1":case"t":case"T":case"true":case"TRUE":case"True":return true;case"0":case"f":case"F":case"false":case"FALSE":case"False":return false;default:throw new Error(`parseBool syntax error: ${e}`)}}static formatFileSize(e){if(e===0)return"0 Bytes";const t=1024;const n=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];const o=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,o)).toFixed(2))+" "+n[o]}static generateRandomString(e=10){const t=p.randomBytes(Math.ceil(e/2));return t.toString("hex").slice(0,e)}static stringToUnicodeEntities(e){return Array.from(e).map((e=>`&#x${e.charCodeAt(0).toString(16)};`)).join("")}static countLines(e){return e.split(/\r\n|\r|\n/).length}static isPathRelativeTo(e,t){const n=C.resolve(e);const o=C.resolve(t);return o.startsWith(n.endsWith(C.sep)?n:`${n}${C.sep}`)}static formatDuration(e){if(e===0)return"0s";const t=Math.floor(e/1e9);const n=Math.floor(t/3600);const o=Math.floor(t%3600/60);const i=t%60;const c=[];if(n)c.push(`${n}h`);if(o)c.push(`${o}m`);if(i||c.length===0)c.push(`${i}s`);return c.join("")}}class Docker{static get configDir(){return process.env.DOCKER_CONFIG||C.join(c.homedir(),".docker")}static configFile(){const e=C.join(Docker.configDir,"config.json");if(!y.existsSync(e)){return undefined}return JSON.parse(y.readFileSync(e,{encoding:"utf-8"}))}static async isAvailable(){return await which("docker",true).then((e=>{core_debug(`Docker.isAvailable ok: ${e}`);return true})).catch((e=>{core_debug(`Docker.isAvailable error: ${e}`);return false}))}static async isDaemonRunning(){try{await Docker.getExecOutput([`version`],{silent:true});return true}catch{return false}}static async exec(e,t){return Exec.exec("docker",e,Docker.execOptions(t))}static async getExecOutput(e,t){return Exec.getExecOutput("docker",e,Docker.execOptions(t))}static execOptions(e){if(!e){e={}}if(!e.env){e.env=Object.assign({},process.env,{DOCKER_CONTENT_TRUST:"false"})}else{e.env.DOCKER_CONTENT_TRUST="false"}return e}static async context(e){const t=["context","inspect","--format","{{.Name}}"];if(e){t.push(e)}return await Docker.getExecOutput(t,{ignoreReturnCode:true,silent:true}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){throw new Error(e.stderr)}return e.stdout.trim()}))}static async contextInspect(e){const t=["context","inspect","--format=json"];if(e){t.push(e)}return await Docker.getExecOutput(t,{ignoreReturnCode:true,silent:true}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){throw new Error(e.stderr.trim())}return JSON.parse(e.stdout.trim())[0]}))}static async printVersion(){await Docker.exec(["version"])}static async printInfo(){await Docker.exec(["info"])}static parseRepoTag(e){let t;const n=e.indexOf("@");const o=e.lastIndexOf(":");if(n>=0){t=n}else if(o>=0){t=o}else{return{repository:e,tag:"latest"}}const i=e.slice(t+1);if(i.indexOf("/")===-1){return{repository:e.slice(0,t),tag:i}}return{repository:e,tag:"latest"}}static async pull(e,t){const n=Docker.parseRepoTag(e);const o=n.repository.replace(/[^a-zA-Z0-9.]+/g,"--");const i=n.tag.replace(/[^a-zA-Z0-9.]+/g,"--");const c=new Cache({htcName:o,htcVersion:i,baseCacheDir:C.join(Docker.configDir,".cache","images",o),cacheFile:"image.tar"});let d;if(t){d=await c.find();if(d){info(`Image found from cache in ${d}`);await Docker.getExecOutput(["load","-i",d],{ignoreReturnCode:true}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){warning(`Failed to load image from cache: ${e.stderr.match(/(.*)\s*$/)?.[0]?.trim()??"unknown error"}`)}}))}}let p=true;await Docker.getExecOutput(["pull",e],{ignoreReturnCode:true}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){p=false;const t=e.stderr.match(/(.*)\s*$/)?.[0]?.trim()??"unknown error";if(d){warning(`Failed to pull image, using one from cache: ${t}`)}else{throw new Error(t)}}}));if(t&&p){const t=C.join(context_Context.tmpDir(),`${Util.hash(e)}.tar`);await Docker.getExecOutput(["save","-o",t,e],{ignoreReturnCode:true}).then((async e=>{if(e.stderr.length>0&&e.exitCode!=0){warning(`Failed to save image: ${e.stderr.match(/(.*)\s*$/)?.[0]?.trim()??"unknown error"}`)}else{const e=await c.save(t);info(`Image cached to ${e}`)}}))}}}class Buildx{_version;_versionOnce;_standalone;static containerNamePrefix="buildx_buildkit_";constructor(e){this._standalone=e?.standalone;this._version="";this._versionOnce=false}static get configDir(){return process.env.BUILDX_CONFIG||C.join(Docker.configDir,"buildx")}static get refsDir(){return C.join(Buildx.configDir,"refs")}static get refsGroupDir(){return C.join(Buildx.refsDir,"__group__")}static get certsDir(){return C.join(Buildx.configDir,"certs")}async isStandalone(){const e=this._standalone??!await Docker.isAvailable();core_debug(`Buildx.isStandalone: ${e}`);return e}async getCommand(e){const t=await this.isStandalone();return{command:t?"buildx":"docker",args:t?e:["buildx",...e]}}async isAvailable(){const e=await this.getCommand([]);const t=await Exec.getExecOutput(e.command,e.args,{ignoreReturnCode:true,silent:true}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){core_debug(`Buildx.isAvailable cmd err: ${e.stderr.trim()}`);return false}return e.exitCode==0})).catch((e=>{core_debug(`Buildx.isAvailable error: ${e}`);return false}));core_debug(`Buildx.isAvailable: ${t}`);return t}async version(){if(this._versionOnce){return this._version}this._versionOnce=true;const e=await this.getCommand(["version"]);this._version=await Exec.getExecOutput(e.command,e.args,{ignoreReturnCode:true,silent:true}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){throw new Error(e.stderr.trim())}return Buildx.parseVersion(e.stdout.trim())}));return this._version}async printVersion(){const e=await this.getCommand(["version"]);await Exec.exec(e.command,e.args,{failOnStdErr:false})}static parseVersion(e){const t=/\sv?([0-9a-f]{7}|[0-9.]+)/.exec(e);if(!t){throw new Error(`Cannot parse buildx version`)}return t[1]}async versionSatisfies(e,t){const n=t??await this.version();if(!n){core_debug(`Buildx.versionSatisfies false: undefined version`);return false}const o=Of.satisfies(n,e)||/^[0-9a-f]{7}$/.exec(n)!==null;core_debug(`Buildx.versionSatisfies ${n} statisfies ${e}: ${o}`);return o}static resolveCertsDriverOpts(e,t,n){let o;try{o=new URL(t)}catch{return[]}if(o.protocol!="tcp:"){return[]}const i=[];if(Object.keys(n).length==0){return i}let c=o.hostname;if(o.port.length>0){c+=`-${o.port}`}if(n.cacert!==undefined){const e=C.join(Buildx.certsDir,`cacert_${c}.pem`);y.writeFileSync(e,n.cacert);i.push(`cacert=${e}`)}if(n.cert!==undefined){const e=C.join(Buildx.certsDir,`cert_${c}.pem`);y.writeFileSync(e,n.cert);i.push(`cert=${e}`)}if(n.key!==undefined){const e=C.join(Buildx.certsDir,`key_${c}.pem`);y.writeFileSync(e,n.key);i.push(`key=${e}`)}if(e!="remote"){return[]}return i}static localState(e,t){const[n,o,i]=e.split("/");if(!n||!o||!i){throw new Error(`Invalid build reference: ${e}`)}const c=C.join(t||Buildx.refsDir,n,o,i);if(!y.existsSync(c)){throw new Error(`Local state not found in ${c}`)}return Buildx.fixLocalState(JSON.parse(y.readFileSync(c,"utf8")))}static fixLocalState(e){const fnTrimToValidContext=function(e){const t=e.match(/(.*)(https?:\/{1,2}\S+|ssh:\/{1,2}\S+|git:\/{1,2}\S+)/i);if(t&&t.length==3){const e=t[1];let n=t[2];if(n.startsWith("https:/")&&!n.startsWith("https://")){n=n.replace("https:/","https://")}if(n.startsWith("http:/")&&!n.startsWith("http://")){n=n.replace("http:/","http://")}if(n.startsWith("ssh:/")&&!n.startsWith("ssh://")){n=n.replace("ssh:/","ssh://")}if(n.startsWith("git:/")&&!n.startsWith("git://")){n=n.replace("git:/","git://")}return[n,e,true]}return[e,"",false]};const[t,n,o]=fnTrimToValidContext(e.LocalPath);if(o){e.LocalPath=t;if(e.DockerfilePath.indexOf(n)===0){e.DockerfilePath=e.DockerfilePath.substring(n.length)}}e.LocalPath=e.LocalPath.endsWith("/-")?"-":e.LocalPath;e.DockerfilePath=e.DockerfilePath.endsWith("/-")?"-":e.DockerfilePath;return e}static refs(e,t={}){const{dir:n,builderName:o,nodeName:i,since:c}=e;let d=C.resolve(n);if(e.builderName){d=C.join(d,e.builderName)}if(e.nodeName){d=C.join(d,e.nodeName)}if(!y.existsSync(d)){return t}const p=y.readdirSync(d);for(const n of p){const p=C.join(d,n);const Q=y.statSync(p);if(Q.isDirectory()){const c={...e};if(!o){if(n==="__group__"){continue}c.builderName=n}else if(!i){c.nodeName=n}Buildx.refs(c,t)}else{if(c&&Q.mtimeatob(e))).join(" ");let d=atob(t.short).replace(/\s\(line \d+\)$/,"");if(t.url){d+=`\nMore info: ${t.url}`}const p=t.range&&t.range.length>0?t.range[0]?.start.line:undefined;let y=false;for(const t of o){if(t.remote||t.path.endsWith(e)&&t.content===n){i.push({title:c,message:d,file:t.path,startLine:p});y=true;break}}if(!y){core_debug(`Buildx.convertWarningsToGitHubAnnotations: skipping warning without matching Dockerfile ${e}: ${c}`)}}return i}}function getInputs(){return{registry:getInput("registry"),username:getInput("username"),password:getInput("password"),scope:getInput("scope"),ecr:getInput("ecr"),logout:getBooleanInput("logout"),registryAuth:getInput("registry-auth")}}function getAuthList(e){if(e.registryAuth&&(e.registry||e.username||e.password||e.scope||e.ecr)){throw new Error("Cannot use registry-auth with other inputs")}let t=[];if(!e.registryAuth){const n=e.registry||"docker.io";t.push({registry:n,username:e.username,password:e.password,scope:e.scope,ecr:e.ecr||"auto",configDir:scopeToConfigDir(n,e.scope)})}else{t=Qf(e.registryAuth).map((e=>{core_setSecret(e.password);const t=e.registry||"docker.io";return{registry:t,username:e.username,password:e.password,scope:e.scope,ecr:e.ecr||"auto",configDir:scopeToConfigDir(t,e.scope)}}))}if(t.length==0){throw new Error("No registry to login")}return t}function scopeToConfigDir(e,t){if(scopeDisabled()||!t||t===""){return""}let n=Q().join(Buildx.configDir,"config",e==="docker.io"?"registry-1.docker.io":e);if(t.startsWith("@")){n+=t}else{n=Q().join(n,t)}return n}function scopeDisabled(){if(process.env.DOCKER_LOGIN_SCOPE_DISABLED){return Util.parseBool(process.env.DOCKER_LOGIN_SCOPE_DISABLED)}return false}var jh=__nccwpck_require__(8249);var Yh=__nccwpck_require__(9821);var Jh=__nccwpck_require__(1279);const Wh=/^(([0-9]{12})\.(dkr\.ecr|dkr-ecr)\.(.+)\.(on\.aws|amazonaws\.(com(.cn)?|eu)))(\/([^:]+)(:.+)?)?$/;const Kh=/public\.ecr\.aws|ecr-public\.aws\.com/;const isECR=e=>Wh.test(e)||isPubECR(e);const isPubECR=e=>Kh.test(e);const getRegion=e=>{if(isPubECR(e)){return process.env.AWS_REGION||process.env.AWS_DEFAULT_REGION||"us-east-1"}const t=e.match(Wh);if(!t){return""}return t[4]};const getAccountIDs=e=>{if(isPubECR(e)){return[]}const t=e.match(Wh);if(!t){return[]}const n=[t[2]];if(process.env.AWS_ACCOUNT_IDS){n.push(...process.env.AWS_ACCOUNT_IDS.split(","))}return n.filter(((e,t)=>n.indexOf(e)===t))};const getRegistriesData=async(e,t,n)=>{const o=getRegion(e);const i=getAccountIDs(e);const c={};if(i.length>0){core_debug(`Requesting AWS ECR auth token for ${i.join(", ")}`);c["registryIds"]=i}let d;const p=process.env.http_proxy||process.env.HTTP_PROXY||"";if(p){core_debug(`Using http proxy ${p}`);d=new Jr.HttpProxyAgent(p)}let y;const C=process.env.https_proxy||process.env.HTTPS_PROXY||"";if(C){core_debug(`Using https proxy ${C}`);y=new Yr.HttpsProxyAgent(C)}const Q=t&&n?{accessKeyId:t,secretAccessKey:n}:undefined;if(isPubECR(e)){info(`AWS Public ECR detected with ${o} region`);const e=new Yh.ECRPUBLIC({customUserAgent:"docker-login-action",credentials:Q,region:o,requestHandler:new Jh.NodeHttpHandler({httpAgent:d,httpsAgent:y})});const t=await e.getAuthorizationToken(c);if(!t.authorizationData||!t.authorizationData.authorizationToken){throw new Error("Could not retrieve an authorization token from AWS Public ECR")}const n=Buffer.from(t.authorizationData.authorizationToken,"base64").toString("utf-8");const i=n.split(":",2);core_setSecret(i[0]);core_setSecret(i[1]);return[{registry:"public.ecr.aws",username:i[0],password:i[1]}]}else{info(`AWS ECR detected with ${o} region`);const e=new jh.ECR({customUserAgent:"docker-login-action",credentials:Q,region:o,requestHandler:new Jh.NodeHttpHandler({httpAgent:d,httpsAgent:y})});const t=await e.getAuthorizationToken(c);if(!Array.isArray(t.authorizationData)||!t.authorizationData.length){throw new Error("Could not retrieve an authorization token from AWS ECR")}const n=[];for(const e of t.authorizationData){const t=Buffer.from(e.authorizationToken||"","base64").toString("utf-8");const o=t.split(":",2);core_setSecret(o[0]);core_setSecret(o[1]);n.push({registry:e.proxyEndpoint||"",username:o[0],password:o[1]})}return n}};async function login(e){if(/true/i.test(e.ecr)||e.ecr=="auto"&&isECR(e.registry)){await loginECR(e.registry,e.username,e.password,e.scope)}else{await loginStandard(e.registry,e.username,e.password,e.scope)}}async function logout(e,t){let n;if(t!==""){n=Object.assign({},process.env,{DOCKER_CONFIG:t});info(`Alternative config dir: ${t}`)}await Docker.getExecOutput(["logout",e],{ignoreReturnCode:true,env:n}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){warning(e.stderr.trim())}}))}async function loginStandard(e,t,n,o){if(!t&&!n){throw new Error("Username and password required")}if(!t){throw new Error("Username required")}if(!n){throw new Error("Password required")}await loginExec(e,t,n,o)}async function loginECR(e,t,n,o){info(`Retrieving registries data through AWS SDK...`);const i=await getRegistriesData(e,t,n);for(const e of i){await loginExec(e.registry,e.username,e.password,o)}}async function loginExec(e,t,n,o){let i;const c=scopeToConfigDir(e,o);if(c!==""){i=Object.assign({},process.env,{DOCKER_CONFIG:c});info(`Logging into ${e} (scope ${o})...`)}else{info(`Logging into ${e}...`)}await Docker.getExecOutput(["login","--password-stdin","--username",t,e],{ignoreReturnCode:true,silent:true,input:Buffer.from(n),env:i}).then((e=>{if(e.stderr.length>0&&e.exitCode!=0){throw new Error(e.stderr.trim())}info("Login Succeeded!")}))}const Xh=process.env["STATE_registries"]?JSON.parse(process.env["STATE_registries"]):[];const Zh=/true/i.test(process.env["STATE_logout"]||"");function setRegistries(e){saveState("registries",JSON.stringify(e))}function setLogout(e){saveState("logout",e)}async function main(){const e=getInputs();setLogout(e.logout);const t=getAuthList(e);setRegistries(Array.from(new Map(t.map((e=>[`${e.registry}|${e.configDir}`,{registry:e.registry,configDir:e.configDir}]))).values()));if(t.length===1){await login(t[0]);return}for(const e of t){await group(`Login to ${e.registry}`,(async()=>{await login(e)}))}}async function post(){if(!Zh){return}for(const e of Xh){await group(`Logout from ${e.registry}`,(async()=>{await logout(e.registry,e.configDir)}))}}run(main,post);var ey=o.i;export{ey as main};