Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix add-pr-url to handle urls that already include http #35

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading