https://github.com/cssnr/web-request-action
Web Request Action
https://github.com/cssnr/web-request-action
github-actions
Last synced: 4 months ago
JSON representation
Web Request Action
- Host: GitHub
- URL: https://github.com/cssnr/web-request-action
- Owner: cssnr
- License: gpl-3.0
- Created: 2024-07-28T07:32:45.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2026-01-03T05:43:53.000Z (5 months ago)
- Last Synced: 2026-01-07T09:30:31.937Z (5 months ago)
- Topics: github-actions
- Language: JavaScript
- Homepage: https://actions.cssnr.com
- Size: 536 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
[](https://github.com/cssnr/web-request-action/tags)
[](https://github.com/cssnr/web-request-action/releases)
[](https://github.com/cssnr/web-request-action/releases/latest)
[](https://github.com/cssnr/web-request-action/blob/master/src/index.js)
[](https://github.com/cssnr/web-request-action/blob/master/action.yml)
[](https://github.com/cssnr/web-request-action/actions/workflows/release.yaml)
[](https://github.com/cssnr/web-request-action/actions/workflows/test.yaml)
[](https://github.com/cssnr/web-request-action/actions/workflows/lint.yaml)
[](https://sonarcloud.io/summary/new_code?id=cssnr_web-request-action)
[](https://github.com/cssnr/web-request-action/pulse)
[](https://codeberg.org/cssnr/web-request-action)
[](https://github.com/cssnr/web-request-action/graphs/contributors)
[](https://github.com/cssnr/web-request-action?tab=readme-ov-file#readme)
[](https://github.com/cssnr/web-request-action)
[](https://github.com/cssnr/web-request-action/forks)
[](https://github.com/cssnr/web-request-action/discussions)
[](https://github.com/cssnr/web-request-action/stargazers)
[](https://cssnr.github.io/)
[](https://discord.gg/wXy6m2X8wY)
[](https://ko-fi.com/cssnr)
# Web Request Action
- [Inputs](#Inputs)
- [Outputs](#Outputs)
- [Examples](#Examples)
- [Tags](#Tags)
- [Support](#Support)
- [Contributing](#Contributing)
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.
```yaml
- 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.txt
```
> [!NOTE]
> Please submit a [Feature Request](https://github.com/cssnr/web-request-action/discussions/categories/feature-requests)
> for new features or [Open an Issue](https://github.com/cssnr/web-request-action/issues) if you find any bugs.
## Inputs
| Input | Default Value | Description of the Input Value |
| :------- | :----------------- | :------------------------------------------------- |
| url | _Required_ | URL for Request [⤵️](#url) |
| method | `POST` | Request Method [⤵️](#method) |
| data | - | Request Data JSON/YAML [⤵️](#data) |
| headers | - | Request Headers JSON/YAML [⤵️](#headers) |
| params | - | Request Parameters JSON/YAML [⤵️](#params) |
| config | - | Axios Config JSON/YAML [⤵️](#config) |
| username | - | Basic Auth Username |
| password | - | Basic Auth Password |
| insecure | `false` | Ignore SSL Errors |
| file | - | File Path to Send [⤵️](#file) |
| name | `file` | File Form Key Name |
| filename | _Original Name_ | Set a Different File Name |
| path | - | Parse a JSON Path result |
### url
The URL to send the request too. You may include params here or in the [params](#params) key.
### method
The request method, including custom methods. Case-insensitive.
Default: `POST`
### data
Body JSON/YAML data. Only used for `PUT`, `POST`, `DELETE`, and `PATCH`.
Data is parsed with `JSON.parse` or `yaml.load`, [js-yaml](https://github.com/nodeca/js-yaml).
View JSON/YAML Example
This format works for `data`, `headers`, `params`, and `config`.
```yaml
data: |
key1: value1
key2: value2
```
```yaml
data: |
{
"key1": "value1",
"key2": "value2"
}
```
```yaml
data: '{"key1": "value1", "key2": "value2"}'
```
Note: All these examples are identical.
### headers
Headers JSON/YAML data.
### params
Parameters (Query String) JSON/YAML data. These may also be provided in the [url](#url).
### config
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.
```javascript
config = { url, method, headers, params, data, auth, httpsAgent, ...config }
```
### file
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](#examples) for more usage options...
## Outputs
| 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.
```yaml
- 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 }}'
```
## Examples
💡 _Click on an example heading to expand or collapse the example._
Trigger a Webhook
```yaml
- name: 'Portainer Webhook'
uses: cssnr/web-request-action@v2
with:
url: ${{ secrets.PORTAINER_WEBHOOK }}
```
Start Algolia Crawl
```yaml
- 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
```yaml
- 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
```yaml
- name: 'Web Request'
uses: cssnr/web-request-action@v2
with:
url: https://httpbin.org/get
method: 'GET'
```
Send Data
```yaml
- name: 'Web Request'
uses: cssnr/web-request-action@v2
with:
url: https://httpbin.org/post
data: '{"key": "value"}'
data: |
'{"key": "value"}'
data: |
key: value
```
Note: All data keys are identical as exemplar formats.
Send File
```yaml
- 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 name
```
Set Axios Config
```yaml
- name: 'Web Request'
uses: cssnr/web-request-action@v2
with:
url: https://httpbin.org/post
config: |
timeout: 1000
maxContentLength: 2000
```
Reference: https://axios-http.com/docs/req_config
All Inputs
```yaml
- 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.txt
```
For more examples, you can check out other projects using this action:
https://github.com/cssnr/web-request-action/network/dependents
## Tags
The following rolling [tags](https://github.com/cssnr/web-request-action/tags) are maintained.
| Tag | Example | Target | Bugs | Feat. | Description |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- | :------- | :--: | :---: | :-------------------------------------------------------- |
| [](https://github.com/cssnr/web-request-action/releases/latest) | `vN` | `vN.x.x` | ✅ | ✅ | Includes new features but is always backwards compatible. |
| [](https://github.com/cssnr/web-request-action/releases/latest) | `vN.N` | `vN.N.x` | ✅ | ❌ | Only receives bug fixes. This is the most stable tag. |
| [](https://github.com/cssnr/web-request-action/releases/latest) | `vN.N.N` | `vN.N.N` | ❌ | ❌ | Not a rolling tag. **Not** recommended. |
You can view the release notes for each version on the [releases](https://github.com/cssnr/web-request-action/releases) page.
# Support
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/](https://cssnr.github.io/feedback/?app=Web%20Request%20Action)
For more information, see the CSSNR [SUPPORT.md](https://github.com/cssnr/.github/blob/master/.github/SUPPORT.md#support).
# Contributing
If you would like to submit a PR, please review the [CONTRIBUTING.md](#contributing-ov-file).
Please consider making a donation to support the development of this project
and [additional](https://cssnr.com/) open source projects.
[](https://ko-fi.com/cssnr)
[](https://actions-tools.cssnr.com/)
Additionally, you can support other [GitHub Actions](https://actions.cssnr.com/) I have published:
- [Stack Deploy Action](https://github.com/cssnr/stack-deploy-action?tab=readme-ov-file#readme)
- [Portainer Stack Deploy Action](https://github.com/cssnr/portainer-stack-deploy-action?tab=readme-ov-file#readme)
- [Docker Context Action](https://github.com/cssnr/docker-context-action?tab=readme-ov-file#readme)
- [Actions Up Action](https://github.com/cssnr/actions-up-action?tab=readme-ov-file#readme)
- [Rhysd Actionlint Action](https://github.com/cssnr/actionlint-action?tab=readme-ov-file#readme)
- [Zensical Action](https://github.com/cssnr/zensical-action?tab=readme-ov-file#readme)
- [VirusTotal Action](https://github.com/cssnr/virustotal-action?tab=readme-ov-file#readme)
- [Mirror Repository Action](https://github.com/cssnr/mirror-repository-action?tab=readme-ov-file#readme)
- [Update Version Tags Action](https://github.com/cssnr/update-version-tags-action?tab=readme-ov-file#readme)
- [Docker Tags Action](https://github.com/cssnr/docker-tags-action?tab=readme-ov-file#readme)
- [TOML Action](https://github.com/cssnr/toml-action?tab=readme-ov-file#readme)
- [Update JSON Value Action](https://github.com/cssnr/update-json-value-action?tab=readme-ov-file#readme)
- [JSON Key Value Check Action](https://github.com/cssnr/json-key-value-check-action?tab=readme-ov-file#readme)
- [Parse Issue Form Action](https://github.com/cssnr/parse-issue-form-action?tab=readme-ov-file#readme)
- [Cloudflare Purge Cache Action](https://github.com/cssnr/cloudflare-purge-cache-action?tab=readme-ov-file#readme)
- [Mozilla Addon Update Action](https://github.com/cssnr/mozilla-addon-update-action?tab=readme-ov-file#readme)
- [Package Changelog Action](https://github.com/cssnr/package-changelog-action?tab=readme-ov-file#readme)
- [NPM Outdated Check Action](https://github.com/cssnr/npm-outdated-action?tab=readme-ov-file#readme)
- [Label Creator Action](https://github.com/cssnr/label-creator-action?tab=readme-ov-file#readme)
- [Algolia Crawler Action](https://github.com/cssnr/algolia-crawler-action?tab=readme-ov-file#readme)
- [Upload Release Action](https://github.com/cssnr/upload-release-action?tab=readme-ov-file#readme)
- [Check Build Action](https://github.com/cssnr/check-build-action?tab=readme-ov-file#readme)
- [Web Request Action](https://github.com/cssnr/web-request-action?tab=readme-ov-file#readme)
- [Get Commit Action](https://github.com/cssnr/get-commit-action?tab=readme-ov-file#readme)
❔ Unpublished Actions
These actions are not published on the Marketplace, but may be useful.
- [cssnr/create-files-action](https://github.com/cssnr/create-files-action?tab=readme-ov-file#readme) - Create various files from templates.
- [cssnr/draft-release-action](https://github.com/cssnr/draft-release-action?tab=readme-ov-file#readme) - Keep a draft release ready to publish.
- [cssnr/env-json-action](https://github.com/cssnr/env-json-action?tab=readme-ov-file#readme) - Convert env file to json or vice versa.
- [cssnr/push-artifacts-action](https://github.com/cssnr/push-artifacts-action?tab=readme-ov-file#readme) - Sync files to a remote host with rsync.
- [smashedr/update-release-notes-action](https://github.com/smashedr/update-release-notes-action?tab=readme-ov-file#readme) - Update release notes.
- [smashedr/combine-release-notes-action](https://github.com/smashedr/combine-release-notes-action?tab=readme-ov-file#readme) - Combine release notes.
---
📝 Template Actions
These are basic action templates that I use for creating new actions.
- [javascript-action](https://github.com/smashedr/javascript-action?tab=readme-ov-file#readme) - JavaScript
- [typescript-action](https://github.com/smashedr/typescript-action?tab=readme-ov-file#readme) - TypeScript
- [py-test-action](https://github.com/smashedr/py-test-action?tab=readme-ov-file#readme) - Dockerfile Python
- [test-action-uv](https://github.com/smashedr/test-action-uv?tab=readme-ov-file#readme) - Dockerfile Python UV
- [docker-test-action](https://github.com/smashedr/docker-test-action?tab=readme-ov-file#readme) - Docker Image Python
Note: The `docker-test-action` builds, runs and pushes images to [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry).
---
For a full list of current projects visit: [https://cssnr.github.io/](https://cssnr.github.io/)