Easily make a web request from a workflow using Axios. Supports all methods, uploading files, basic authentication and more. Pass data/headers/params as JSON or YAML formatted strings.
- name: 'Web Request'
uses: cssnr/web-request-action@v2
with:
url: https://httpbin.org/post
method: 'POST'
data: '{"key": "value"}'
headers: |
key: value
params: |
{
"key": "value"
}
config: |
timeout: 1000
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
insecure: false
file: path/to/file.txt
name: file
filename: custom-name.txtNote
Please submit a Feature Request for new features or Open an Issue if you find any bugs.
| Input | Default Value | Description of the Input Value |
|---|---|---|
| url | Required | URL for Request |
| method | POST |
Request Method |
| data | - | Request Data JSON/YAML |
| headers | - | Request Headers JSON/YAML |
| params | - | Request Parameters JSON/YAML |
| config | - | Axios Config JSON/YAML |
| username | - | Basic Auth Username |
| password | - | Basic Auth Password |
| insecure | false |
Ignore SSL Errors |
| file | - | File Path to Send |
| name | file |
File Form Key Name |
| filename | Original Name | Set a Different File Name |
| path | - | Parse a JSON Path result |
The URL to send the request too. You may include params here or in the params key.
The request method, including custom methods. Case-insensitive.
Default: POST
Body JSON/YAML data. Only used for PUT, POST, DELETE, and PATCH.
Data is parsed with JSON.parse or yaml.load, js-yaml.
View JSON/YAML Example
This format works for data, headers, params, and config.
data: |
key1: value1
key2: value2data: |
{
"key1": "value1",
"key2": "value2"
}data: '{"key1": "value1", "key2": "value2"}'Note: All these examples are identical.
Headers JSON/YAML data.
Parameters (Query String) JSON/YAML data. These may also be provided in the url.
Additional Axios Config JSON/YAML data. For example, set a 3-second timeout: timeout: 3000
Reference: https://axios-http.com/docs/req_config
Note: The config is spread last and overrides other keys.
config = { url, method, headers, params, data, auth, httpsAgent, ...config }When sending a file, multipart/form-data wil be used and data will be added to the form data with the
key name. The file path is relative to the workspace/working directory.
For more information on inputs, see: https://axios-http.com/docs/req_config
See the Examples for more usage options...
| Output | Description |
|---|---|
| status | Response Status |
| headers | Response Headers |
| data | Response Data |
| result | JSON Path Result |
Note: All outputs are run through JSON.stringify by default.
- name: 'Web Request'
id: test
uses: cssnr/web-request-action@v2
with:
url: https://httpbin.org/post
- name: 'Echo Output'
run: |
echo '${{ steps.test.outputs.status }}'
echo '${{ steps.test.outputs.headers }}'
echo '${{ steps.test.outputs.data }}'💡 Click on an example heading to expand or collapse the example.
Trigger a Webhook
- name: 'Portainer Webhook'
uses: cssnr/web-request-action@v2
with:
url: ${{ secrets.PORTAINER_WEBHOOK }}Start Algolia Crawl
- name: 'Start Algolia Crawl'
uses: cssnr/web-request-action@v2
with:
url: https://crawler.algolia.com/api/1/crawlers/${{ secrets.CRAWLER_ID }}/reindex
username: ${{ secrets.CRAWLER_USER_ID }}
password: ${{ secrets.CRAWLER_API_KEY }}Deploy to Render
- name: 'Render Deploy Image'
uses: cssnr/web-request-action@v2
with:
url: ${{ secrets.RENDER_HOOK }}
params: |
imgURL: ghcr.io/${{ github.repository }}:${{ github.ref_name }}Make a GET Request
- name: 'Web Request'
uses: cssnr/web-request-action@v2
with:
url: https://httpbin.org/get
method: 'GET'Send Data
- name: 'Web Request'
uses: cssnr/web-request-action@v2
with:
url: https://httpbin.org/post
data: '{"key": "value"}'
data: |
'{"key": "value"}'
data: |
key: valueNote: All data keys are identical as exemplar formats.
Send File
- name: 'Web Request'
uses: cssnr/web-request-action@v2
with:
url: https://httpbin.org/post
file: path/to/file.txt
name: file # Default - name of file key
filename: name.txt # Optional - file nameSet Axios Config
- name: 'Web Request'
uses: cssnr/web-request-action@v2
with:
url: https://httpbin.org/post
config: |
timeout: 1000
maxContentLength: 2000Reference: https://axios-http.com/docs/req_config
All Inputs
- name: 'Web Request'
uses: cssnr/web-request-action@v2
with:
url: https://httpbin.org/post
method: 'POST'
data: '{"key": "value"}'
headers: |
key: value
params: |
{
"key": "value"
}
config: |
timeout: 5000
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
insecure: false
file: path/to/file.txt
name: file
filename: name.txtFor more examples, you can check out other projects using this action:
https://github.com/cssnr/web-request-action/network/dependents
The following rolling tags are maintained.
You can view the release notes for each version on the releases page.
For general help or to request a feature, see:
- Q&A Discussion: https://github.com/cssnr/web-request-action/discussions/categories/q-a
- Request a Feature: https://github.com/cssnr/web-request-action/discussions/categories/feature-requests
If you are experiencing an issue/bug or getting unexpected results, you can:
- Report an Issue: https://github.com/cssnr/web-request-action/issues
- Chat with us on Discord: https://discord.gg/wXy6m2X8wY
- Provide General Feedback: https://cssnr.github.io/feedback/
For more information, see the CSSNR SUPPORT.md.
If you would like to submit a PR, please review the CONTRIBUTING.md.
Please consider making a donation to support the development of this project and additional open source projects.
Additionally, you can support other GitHub Actions I have published:
- Stack Deploy Action
- Portainer Stack Deploy Action
- Docker Context Action
- Actions Up Action
- Rhysd Actionlint Action
- Zensical Action
- VirusTotal Action
- Mirror Repository Action
- Update Version Tags Action
- Docker Tags Action
- TOML Action
- Update JSON Value Action
- JSON Key Value Check Action
- Parse Issue Form Action
- Cloudflare Purge Cache Action
- Mozilla Addon Update Action
- Package Changelog Action
- NPM Outdated Check Action
- Label Creator Action
- Algolia Crawler Action
- Upload Release Action
- Check Build Action
- Web Request Action
- Get Commit Action
❔ Unpublished Actions
These actions are not published on the Marketplace, but may be useful.
- cssnr/create-files-action - Create various files from templates.
- cssnr/draft-release-action - Keep a draft release ready to publish.
- cssnr/env-json-action - Convert env file to json or vice versa.
- cssnr/push-artifacts-action - Sync files to a remote host with rsync.
- smashedr/update-release-notes-action - Update release notes.
- smashedr/combine-release-notes-action - Combine release notes.
📝 Template Actions
These are basic action templates that I use for creating new actions.
- javascript-action - JavaScript
- typescript-action - TypeScript
- py-test-action - Dockerfile Python
- test-action-uv - Dockerfile Python UV
- docker-test-action - Docker Image Python
Note: The docker-test-action builds, runs and pushes images to GitHub Container Registry.
For a full list of current projects visit: https://cssnr.github.io/
