From bb84d03b7e69e802a2a3b901daa0e70104785a16 Mon Sep 17 00:00:00 2001 From: Edwin Sirko Date: Tue, 23 Jan 2024 15:24:45 -0500 Subject: [PATCH] v0.0.52: fetch CR URL --- action.yml | 2 +- dist/index.js | 7 ++++++- src/main.ts | 10 +++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 96428a3..3bb14d6 100644 --- a/action.yml +++ b/action.yml @@ -33,7 +33,7 @@ runs: shell: bash # - run: node ./dist/index.js # shell: bash - - uses: ddivad195/publish-action-package/package-and-publish@v0.0.51 + - uses: ddivad195/publish-action-package/package-and-publish@v0.0.52 id: publish - name: Output variables shell: bash diff --git a/dist/index.js b/dist/index.js index 329b6bf..149fcbc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -74764,7 +74764,12 @@ async function run() { } // Gather & validate user inputs const token = core.getInput('token'); - const registryURL = new URL('https://ghcr.io/'); // TODO: Should this be dynamic? Maybe an API endpoint to grab the registry for GHES/proxima purposes. + //const response = await fetch('http://echo.jsontest.com/url/https:--ghcr.io') // for testing locally + const response = await fetch(process.env.GITHUB_API_URL + '/packages/container-registry-url'); + if (!response.ok) { + throw new Error(`Failed to fetch status page: ${response.statusText}`); + } + const registryURL = new URL(await (await response.json()).url); console.log(core.getInput('registry')); console.log(`registryURL: ${registryURL}`); // Paths to be included in the OCI image diff --git a/src/main.ts b/src/main.ts index fac1975..64d3597 100644 --- a/src/main.ts +++ b/src/main.ts @@ -39,7 +39,15 @@ export async function run(): Promise { // Gather & validate user inputs const token: string = core.getInput('token') - const registryURL: URL = new URL('https://ghcr.io/') // TODO: Should this be dynamic? Maybe an API endpoint to grab the registry for GHES/proxima purposes. + + //const response = await fetch('http://echo.jsontest.com/url/https:--ghcr.io') // for testing locally + const response = await fetch( + process.env.GITHUB_API_URL + '/packages/container-registry-url' + ) + if (!response.ok) { + throw new Error(`Failed to fetch status page: ${response.statusText}`) + } + const registryURL: URL = new URL(await (await response.json()).url) console.log(core.getInput('registry')) console.log(`registryURL: ${registryURL}`) // Paths to be included in the OCI image