@@ -32374,11 +32374,11 @@ function buildRequestPayload(steps, githubContext) {
3237432374 steps: steps
3237532375 };
3237632376}
32377- async function registerSource(baseUrl, bbRunUuid , requestPayload, requestHeaders, tokenFilePath, coreAdapter) {
32377+ async function registerSource(buildingBlockRunUrl , requestPayload, requestHeaders, tokenFilePath, coreAdapter) {
3237832378 coreAdapter.debug(`Request Payload: ${JSON.stringify(requestPayload)}`);
3237932379 coreAdapter.debug(`Request Headers: ${JSON.stringify(requestHeaders)}`);
3238032380 try {
32381- const response = await axios_1.default.post(`${baseUrl}/api/meshobjects/meshbuildingblockruns/${bbRunUuid }/status/source`, requestPayload, {
32381+ const response = await axios_1.default.post(`${buildingBlockRunUrl }/status/source`, requestPayload, {
3238232382 headers: requestHeaders
3238332383 });
3238432384 coreAdapter.setOutput('response', response.data);
@@ -32403,25 +32403,26 @@ async function registerSource(baseUrl, bbRunUuid, requestPayload, requestHeaders
3240332403async function runRegisterSource(coreAdapter = core, githubContext = github) {
3240432404 try {
3240532405 const stepsInput = coreAdapter.getInput('steps');
32406- const buildingBlockRunUrl = coreAdapter.getInput('buildingBlockRunUrl');
32406+ // Extract buildingBlockRunUrl and buildingBlockRun from GitHub event payload
32407+ const buildingBlockRunUrl = githubContext.context.payload.inputs?.buildingBlockRunUrl;
32408+ const buildingBlockRun = githubContext.context.payload.inputs?.buildingBlockRun;
3240732409 coreAdapter.debug(`Steps Input: ${stepsInput}`);
3240832410 coreAdapter.debug(`Building Block Run URL: ${buildingBlockRunUrl}`);
32411+ coreAdapter.debug(`Building Block Run: ${buildingBlockRun}`);
3240932412 // Load token
3241032413 const { token, tokenFilePath } = loadTokenFromFile(coreAdapter);
32411- // Load building block run
32414+ // Load building block run and determine the run URL
3241232415 let buildingBlockRunJson;
32416+ let runUrl;
3241332417 if (buildingBlockRunUrl) {
3241432418 buildingBlockRunJson = await loadBuildingBlockRunFromUrl(buildingBlockRunUrl, token, coreAdapter);
32419+ runUrl = buildingBlockRunUrl;
3241532420 }
3241632421 else {
32417- const buildingBlockRun = githubContext.context.payload.inputs.buildingBlockRun;
3241832422 buildingBlockRunJson = loadBuildingBlockRunFromBase64(buildingBlockRun, coreAdapter);
32423+ runUrl = buildingBlockRunJson._links.self.href;
3241932424 }
32420- // Extract common data from buildingBlockRunJson
32421- const bbRunUuid = buildingBlockRunJson.metadata.uuid;
32422- const baseUrl = buildingBlockRunJson._links.meshstackBaseUrl.href;
32423- coreAdapter.debug(`Base URL: ${baseUrl}`);
32424- coreAdapter.debug(`BB Run UUID: ${bbRunUuid}`);
32425+ coreAdapter.debug(`Building Block Run URL: ${runUrl}`);
3242532426 // Extract inputs and write to outputs
3242632427 extractInputs(buildingBlockRunJson, coreAdapter);
3242732428 // Parse the JSON steps input
@@ -32431,7 +32432,7 @@ async function runRegisterSource(coreAdapter = core, githubContext = github) {
3243132432 const requestPayload = buildRequestPayload(steps, githubContext);
3243232433 const requestHeaders = buildRequestHeaders(token);
3243332434 // Register the source
32434- await registerSource(baseUrl, bbRunUuid , requestPayload, requestHeaders, tokenFilePath, coreAdapter);
32435+ await registerSource(runUrl , requestPayload, requestHeaders, tokenFilePath, coreAdapter);
3243532436 }
3243632437 catch (error) {
3243732438 if (error instanceof Error) {
0 commit comments