From b0a8874faf154baf9ec17ee8c3dc7cf0dd9723b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogi=20Napoleon=20Wennerstr=C3=B8m?= Date: Wed, 23 Mar 2022 13:53:02 +0100 Subject: [PATCH] Support AWS' Github Integration (Version 2). This closes #14 --- src/index.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index 6eb6d11..4ac206d 100644 --- a/src/index.js +++ b/src/index.js @@ -72,16 +72,23 @@ exports.getPipelineExecution = async (pipelineName, executionId) => { const artifactRevision = result.pipelineExecution.artifactRevisions[0]; const revisionURL = artifactRevision.revisionUrl; - const sha = artifactRevision.revisionId; const pattern = /github.com\/(.+)\/(.+)\/commit\//; const matches = pattern.exec(revisionURL); - return { - owner: matches[1], - repository: matches[2], - sha: sha - }; + if (matches !== null) { + const sha = artifactRevision.revisionId; + + return { owner: matches[1], repository: matches[2], sha }; + } + + const revisionParams = new URLSearchParams(new URL(revisionURL).search); + const fullRepository = revisionParams.get('FullRepositoryId'); + const owner = fullRepository.split('/')[0]; + const repository = fullRepository.split('/')[1]; + const sha = revisionParams.get('Commit'); + + return { owner, repository, sha }; }; exports.postStatusToGitHub = async (owner, repository, sha, payload) => {