From a322eeec975cf790b41517c54277acf37b4dfabb Mon Sep 17 00:00:00 2001 From: Mike Potter Date: Fri, 14 Jun 2024 14:04:49 -0700 Subject: [PATCH] Handle add-pr-url when url already includes http --- .github/workflows/test.yml | 5 +++++ actions/add-pr-url/action.yml | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4115195..d41fa52 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,6 +54,11 @@ jobs: with: url: www.example.com caption: Test Link + - name: Add existing https link to PR + uses: phase2/octane-actions/actions/add-pr-url@develop + with: + url: https://www.example.com + caption: Test Https Link - name: Add second url link to PR uses: phase2/octane-actions/actions/add-pr-url@develop with: diff --git a/actions/add-pr-url/action.yml b/actions/add-pr-url/action.yml index 78e8b3e..85de815 100644 --- a/actions/add-pr-url/action.yml +++ b/actions/add-pr-url/action.yml @@ -29,11 +29,15 @@ runs: let now = new Date(); console.log(now.toUTCString()); console.log(context.payload) + let url = `${{ inputs.url }}`; + if (! url.startsWith('http')) { + url = `https://${url}`; + } let caption = '${{ inputs.caption }}' if (! caption) { - caption = 'View environment ${{ inputs.url }}' + caption = 'View environment ${url}' } - const snippet = `

:arrow_forward:  ${caption}

` + const snippet = `

:arrow_forward:  ${caption}

` const owner = context.payload.repository.owner.login const repo = context.payload.repository.name let fetch_body = '${{ inputs.fetch }}'