Skip to content

Commit

Permalink
Handle add-pr-url when url already includes http
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-potter committed Jun 14, 2024
1 parent 988cf3e commit a322eee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions actions/add-pr-url/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<h3><a href="https://${{ inputs.url }}">:arrow_forward:&nbsp;&nbsp;${caption}</a></h3>`
const snippet = `<h3><a href="${url}">:arrow_forward:&nbsp;&nbsp;${caption}</a></h3>`
const owner = context.payload.repository.owner.login
const repo = context.payload.repository.name
let fetch_body = '${{ inputs.fetch }}'
Expand Down

0 comments on commit a322eee

Please sign in to comment.