Skip to content

skgandikota/FetchUrl

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FetchUrl GitHub Action

A GitHub Action that performs HTTP requests using the Fetch API and returns the response status, headers, and body. Supports all HTTP methods. Completely stateless — no data is stored or logged.

Inputs

Input Required Default Description
url Yes The URL to fetch
method No GET HTTP method (GET, POST, PUT, DELETE, PATCH, etc.)
headers No {} JSON string of request headers
body No Request body (ignored for GET/HEAD)
timeout No 30000 Request timeout in milliseconds (0 = no timeout)

Outputs

Output Description
status The HTTP response status code
headers The HTTP response headers as a JSON string
body The HTTP response body

Example GET Usage

jobs:
  getRequest_job:
    name: "SAMPLE GET REQUEST"
    runs-on: ubuntu-latest
    steps:
      - name: GET REQUEST SAMPLE
        id: getRequest
        uses: skgandikota/FetchUrl@v2
        with:
          url: "https://jsonplaceholder.typicode.com/posts/1"

      - name: Get the getRequest outputs
        run: |
          echo "status: ${{ steps.getRequest.outputs.status }}"
          echo "date: $(echo '${{ steps.getRequest.outputs.headers }}' | jq -r '.date')"
          echo "responseBody: ${{ steps.getRequest.outputs.body }}"

Example POST Usage

jobs:
  postRequest_job:
    name: "SAMPLE POST REQUEST"
    runs-on: ubuntu-latest
    steps:
      - name: POST REQUEST SAMPLE
        id: postRequest
        uses: skgandikota/FetchUrl@v2
        with:
          url: "https://jsonplaceholder.typicode.com/posts"
          method: POST
          headers: '{"Content-type": "application/json; charset=UTF-8"}'
          body: '{"title": "foo", "body": "bar", "userId": 1}'

      - name: Get the postRequest outputs
        run: |
          echo "status: ${{ steps.postRequest.outputs.status }}"
          echo "responseBody: ${{ steps.postRequest.outputs.body }}"

Migration from v1 to v2

Breaking Changes

  • Runtime upgraded from node16 to node20 — GitHub deprecated Node.js 16 runners. No action needed if you pin to @v2.
  • node-fetch replaced with built-in fetch — Response headers are now a flat JSON object ({"date": "..."}) instead of arrays ({"date": ["..."]}). Update any header parsing logic.
  • Non-JSON responses now work — Previously the action called response.json() unconditionally, which threw on HTML/text/XML responses. It now falls back to plain text.
  • body default changed — from "null" (string) to empty string. No impact for most users.

New Features

  • timeout input (default 30s) with AbortController
  • Proper async/await error handling — failures now correctly call core.setFailed()

License

MIT

About

GitHub Action that performs generic HTTP requests using the Fetch API. Returns status, headers, and body. Supports all HTTP methods, custom headers, request body, and timeouts.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors