Skip to content

Commit

Permalink
Add support for content type, and default type json
Browse files Browse the repository at this point in the history
  • Loading branch information
kvanbere committed Oct 7, 2023
1 parent 106c5fd commit 04d825d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ inputs:
uri:
required: true
description: "Invoke the specified URI"
content-type:
description: "Set the content type of the request"
default: 'application/json'
filename:
description: "Save the output to the specified file"
user-agent:
Expand All @@ -18,6 +21,12 @@ inputs:
retries:
description: "Retry the request if it fails"
default: 3
retry-interval:
description: "The retry interval in seconds"
default: 5
retry-timeout:
description: "The time in seconds before each request will timeout and retry if possible"
default: 60
runs:
using: "composite"
steps:
Expand All @@ -30,10 +39,13 @@ runs:
if: runner.os == 'Windows'
shell: pwsh
env:
URI: ${{ format('-Uri {0}', inputs.uri) }}
URI: ${{ format('-Uri "{0}"', inputs.uri) }}
CONTENT_TYPE: ${{ format(' -ContentType "{0}"', inputs.content-type) }}
FILENAME: ${{ inputs.filename != '' && format(' -OutFile "{0}"', inputs.filename) || '' }}
USER_AGENT: ${{ inputs.user-agent != '' && format(' -UserAgent "{0}"', inputs.user-agent) || '' }}
MAX_REDIRECTIONS: ${{ inputs.max-redirections != 5 && format(' -MaximumRedirection {0}', inputs.max-redirections) || '' }}
RETRIES: ${{ inputs.retries != 3 && format(' -MaximumRetryCount {0}', inputs.retries) || '' }}
RETRY_INTERVAL: ${{ inputs.retry-interval != 5 && format(' -RetryIntervalSec {0}', inputs.retry-interval) || '' }}
RETRY_TIMEOUT: ${{ inputs.retry-timeout != 5 && format(' -TimeoutSec {0}', inputs.retry-timeout) || '' }}
run: |
Invoke-WebRequest ${{env.URI}}${{env.FILENAME}}${{env.USER_AGENT}}${{env.MAX_REDIRECTIONS}}${{env.RETRIES}}
Invoke-WebRequest ${{env.URI}}${{env.CONTENT_TYPE}}${{env.FILENAME}}${{env.USER_AGENT}}${{env.MAX_REDIRECTIONS}}${{env.RETRIES}}${{env.RETRY_INTERVAL}}${{env.RETRY_TIMEOUT}}

0 comments on commit 04d825d

Please sign in to comment.