-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
67 lines (66 loc) · 3.36 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: 'Invoke URI'
description: 'Call a URI and return the result'
author: foss@cuedo.com.au
branding:
icon: 'link-2'
color: 'orange'
inputs:
method:
description: "Specifies the method used for the web request"
default: 'GET' # Must be all-caps
uri:
required: true
description: "Invoke the specified URI"
content-type:
description: "Set the content type of the request"
default: 'application/json'
# Shall we allow an Accept: setting for the content type?
filename:
description: "Save the output to the specified file"
user-agent:
description: "Custom user agent"
max-redirections:
description: "The maximum number of redirections"
default: 5
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:
- name: Invoke URI (macOS and Linux)
if: runner.os == 'Linux' || runner.os == 'macOS'
shell: bash
env:
METHOD: ${{ format('-X ''{0}''', inputs.method) }}
URI: ${{ format(' --no-progress-meter ''{0}''', inputs.uri) }}
CONTENT_TYPE: "${{ format(' -H ''Content-Type: {0}''', inputs.content-type) }}"
FILENAME: ${{ inputs.filename != '' && format(' -o ''{0}''', inputs.filename) || '' }}
USER_AGENT: ${{ inputs.user-agent != '' && format(' --user-agent ''{0}''', inputs.user-agent) || '' }}
MAX_REDIRECTIONS: ${{ inputs.max-redirections != 5 && format(' --max-redirs {0}', inputs.max-redirections) || '' }}
RETRIES: ${{ inputs.retries != 3 && format(' --retry {0} --retry-all-errors', inputs.retries) || '' }}
RETRY_INTERVAL: ${{ inputs.retry-interval != 5 && format(' -retry-delay {0}', inputs.retry-interval) || '' }}
RETRY_TIMEOUT: ${{ inputs.retry-timeout != 5 && format(' --retry-max-time {0}', inputs.retry-timeout) || '' }}
run: |
curl ${{env.METHOD}}${{env.CONTENT_TYPE}}${{env.FILENAME}}${{env.USER_AGENT}}${{env.MAX_REDIRECTIONS}}${{env.RETRIES}}${{env.RETRY_INTERVAL}}${{env.RETRY_TIMEOUT}}${{env.URI}}
- name: Invoke URI (Windows)
if: runner.os == 'Windows'
shell: pwsh
env:
METHOD: ${{ format('-Method ''{0}''', inputs.method) }}
URI: ${{ format(' -Uri ''{0}''', inputs.uri) }}
CONTENT_TYPE: ${{ format(' -ContentType ''{0}''', inputs.content-type) }}
FILENAME: ${{ inputs.filename != '' && format(' -PassThru -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.METHOD}}${{env.URI}}${{env.CONTENT_TYPE}}${{env.FILENAME}}${{env.USER_AGENT}}${{env.MAX_REDIRECTIONS}}${{env.RETRIES}}${{env.RETRY_INTERVAL}}${{env.RETRY_TIMEOUT}}