Skip to content

Commit

Permalink
simplify URL logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ax-vasquez committed Aug 30, 2023
1 parent 2e38a45 commit 89fe794
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 34 deletions.
21 changes: 4 additions & 17 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74840,6 +74840,7 @@ const detectPrNumber = async () => {
GITHUB_REPOSITORY,
GITHUB_HEAD_REF,
GITHUB_REF,
GITHUB_SERVER_URL,
CYPRESS_PULL_REQUEST_ID,
CYPRESS_PULL_REQUEST_URL
} = process.env
Expand Down Expand Up @@ -74885,23 +74886,9 @@ const detectPrNumber = async () => {
core.exportVariable('CYPRESS_PULL_REQUEST_ID', prNumber)
}

const prResp = await client.request(
'GET /repos/:owner/:repo/pulls/:pull_number',
{
owner,
repo,
pull_number: prNumber
}
)

if (prResp && prResp.data && prResp.data.html_url) {
console.log(`PR URL DETECTED: ${prResp.data.html_url}`)
if (!CYPRESS_PULL_REQUEST_URL) {
core.exportVariable(
'CYPRESS_PULL_REQUEST_URL',
prResp.data.html_url
)
}
const url = `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pulls/${prNumber}`
if (!CYPRESS_PULL_REQUEST_URL) {
core.exportVariable('CYPRESS_PULL_REQUEST_URL', url)
}
}
}
Expand Down
21 changes: 4 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ const detectPrNumber = async () => {
GITHUB_REPOSITORY,
GITHUB_HEAD_REF,
GITHUB_REF,
GITHUB_SERVER_URL,
CYPRESS_PULL_REQUEST_ID,
CYPRESS_PULL_REQUEST_URL
} = process.env
Expand Down Expand Up @@ -489,23 +490,9 @@ const detectPrNumber = async () => {
core.exportVariable('CYPRESS_PULL_REQUEST_ID', prNumber)
}

const prResp = await client.request(
'GET /repos/:owner/:repo/pulls/:pull_number',
{
owner,
repo,
pull_number: prNumber
}
)

if (prResp && prResp.data && prResp.data.html_url) {
console.log(`PR URL DETECTED: ${prResp.data.html_url}`)
if (!CYPRESS_PULL_REQUEST_URL) {
core.exportVariable(
'CYPRESS_PULL_REQUEST_URL',
prResp.data.html_url
)
}
const url = `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pulls/${prNumber}`
if (!CYPRESS_PULL_REQUEST_URL) {
core.exportVariable('CYPRESS_PULL_REQUEST_URL', url)
}
}
}
Expand Down

0 comments on commit 89fe794

Please sign in to comment.