DEV Community

loading...
Cover image for Github Action to get response time details of a URL in a scheduled interval

Github Action to get response time details of a URL in a scheduled interval

sisodiya2421 profile image Abhishek Sisodiya ใƒป2 min read

Being an opensource enthusiast, I am pleased to announce my first Github Action project as a submission to Github Actions hackathon in Dev.to please bear any mistakes that I may have made.

My Workflow

Scheduled Ping is a Github Action that sets a scheduled time interval to ping at your given URL and show you the response time details using cURL.

Alt Text

Submission Category:

Wacky Wildcards

Yaml File or Link to Code

You can integrate this Action in your workflow using this YAML

name: Scheduled Ping
# This workflow is triggered at a scheduled interval of every 30 minutes
on:
  schedule:
    # * is a special character in YAML so you have to quote this string.
    # /30 denotes that it will run once every 30 minutes
    - cron:  '*/30 * * * *'

jobs:
  pinger_job:
    name: A job to ping
    runs-on: ubuntu-latest
    env:
      URL: ${{ secrets.URL }}
    steps:
      - id: ping
        uses: sisodiya2421/pinger@master
Enter fullscreen mode Exit fullscreen mode

For more details on how to set up your URL for Scheduled Ping Action check out the Github Action Repo

GitHub logo sisodiya2421 / pinger

This GitHub action will help you to schedule a ping to a specified URL at certain intervals.

Scheduled Ping

This action pings your specified URL every 30 minutes(changeable) and generates timing details using cURL.

Secrets

URL (Required) The URL to ping must be specified under secrets settings in your repository for this action to work on that URL.

You can go to this Link to get details about adding secrets to your repository

Example usage

Copy the following workflow example code into a .github/workflows/main.yml

Note You may rename main.yml as per your own requirements.

name: Scheduled Ping
# This workflow is triggered at a scheduled interval of every 30 minutes
on
  schedule
    # * is a special character in YAML so you have to quote this string.
    # /30 denotes that it will run once every 30 minutes
    - cron:  '*/30 * * * *'
jobs
  pinger_job:
    name: A job to ping
    runs-on
โ€ฆ
Enter fullscreen mode Exit fullscreen mode

Additional Resources / Info

You can make changes to your workflow as per your own requirements like in place of using schedule event as a trigger to your workflow use may use push or pull events.

You also have the flexibility to change the time interval just by using POSIX cron syntax

Alt Text

Here's Link on how to add URL as a secret in your repo.

Check out Scheduled Ping Action at Github Marketplace

It has been a great journey from learning what is Github action to making a custom action of my own. Going through the docs I am pretty much sure the possibilities are endless.

Discussion (0)

pic
Editor guide